I am trying to interact with this predicate using TS SDK
RECEIVER: Address = Address::from(0x0101010101010101010101010101010101010101010101010101010101010101),
}
fn main() -> bool {
// return true;
// The spending transaction must have an output that sends `ask_amount` of `ask_asset` to `receiver`
let witness_index = 1;
let tx_hash = tx_id(); // Get the transaction hash
let current_signature = tx_witness_data::<B512>(witness_index); // Retrieve the signature at the given index
if current_signature.is_some() {
let current_address = ec_recover_address(current_signature.unwrap(), tx_hash).unwrap(); // Recover the address from the signature and transaction hash
if current_address == RECEIVER {
return true;
}
}
}```
TS code
```const cancel = async () => {
if (!wallet) return;
const transactionRequest = new ScriptTransactionRequest();
const baseAssetId = wallet.provider.getBaseAssetId();
const predicate = await getPredicate(baseAssetId, ASK_AMOUNT, ASSET, wallet.address.toB256());
console.log(predicate?.address.toB256());
if (!predicate) return;
const UtxoToPayFee = await predicate.getResourcesToSpend([
[1, ASSET],
]);
transactionRequest
.addResources(UtxoToPayFee)
.addCoinOutput(wallet.address, 1, ASSET);
transactionRequest.addWitness('0x');
const txCost = await predicate.getTransactionCost(transactionRequest, {
signatureCallback: (tx) => tx.addAccountWitnesses(wallet),
});
transactionRequest.updatePredicateGasUsed(txCost.estimatedPredicates);
transactionRequest.gasLimit = txCost.gasUsed;
transactionRequest.maxFee = txCost.maxFee;
// Fund the transaction from the wallet
await wallet.fund(transactionRequest, txCost);
await transactionRequest.addAccountWitnesses(wallet);
// Sending the transaction to the chain
const tx = await wallet.sendTransaction(transactionRequest);
const res = await tx.waitForResult();
console.log(res);
};
Error I am getting
at Array.map (<anonymous>)
at signatureCallback (Contract.tsx:151:43)
at cancel (Contract.tsx:150:42)```
Fuelup Show
Default host: x86_64-unknown-linux-gnu
fuelup home: /home/chappie/.fuelup
Installed toolchains
--------------------
latest-x86_64-unknown-linux-gnu
nightly-x86_64-unknown-linux-gnu
my_toolchain (default)
testnet-x86_64-unknown-linux-gnu (override)
active toolchain
----------------
testnet-x86_64-unknown-linux-gnu (override), path: /home/chappie/fuelart/fuel-toolchain.toml
forc : 0.66.5
- forc-client
- forc-deploy : not found
- forc-run : not found
- forc-crypto : not found
- forc-debug : not found
- forc-doc : not found
- forc-fmt : not found
- forc-lsp : not found
- forc-tx : not found
- forc-wallet : 0.11.1
fuel-core : 0.40.0
fuel-core-keygen : 0.40.0
fuels versions
--------------
forc : 0.66.10
forc-wallet : 0.66.9
Fuel TS SDK: 0.97.2