I created a predicate and sent an asset to that. Now I want to spend that predicate using TS SDK.
My predicate is just a true return from the main function.
`const tx1 = await predicate.transfer(address, 50, asset1);`
But I am getting an error below
FuelError: Invalid transaction data: PredicateVerificationFailed(Panic(PredicateReturnedNonOne))
at responseMiddleware (index.mjs:4229:19)
at eval (index.js:284:17)
at async _Provider.sendTransaction (index.mjs:4364:9)
at async buy (page.tsx:268:21)```
3 Likes
Can you share all the code
Can you please share the output for the fuelup show
from your terminal and the version of the ts sdk you are using?
1 Like
@chappie1998 Please try to be more detailed so we can understand what’s happening. It’s challenging to assist you with so little context and short code snippets because one must guess a lot about your implementation, and that’s not very productive.
Meanwhile, you can check the docs around spending Predicate’s funds.
3 Likes
Here is my predicate code(mentioned in the message):-
predicate;
fn main() -> bool {
true
}
my TS transfer function
const address =
"0x6b63804cfbf9856e68e5b6e7aef238dc8311ec55bec04df774003a2c96e0418";
const baseAsset =
"0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07";
const tx1 = await predicate.transfer(address, 50, baseAsset);```
fuelup show
Default host: x86_64-unknown-linux-gnu
fuelup home: /home/chappie/.fuelup
Installed toolchains
--------------------
latest-x86_64-unknown-linux-gnu (default)
testnet-x86_64-unknown-linux-gnu
active toolchain
----------------
latest-x86_64-unknown-linux-gnu (default)
forc : 0.61.2
- forc-client
- forc-deploy : 0.61.2
- forc-run : 0.61.2
- forc-crypto : 0.61.2
- forc-debug : 0.61.2
- forc-doc : 0.61.2
- forc-fmt : 0.61.2
- forc-lsp : 0.61.2
- forc-tx : 0.61.2
- forc-wallet : 0.8.1
fuel-core : 0.31.0
fuel-core-keygen : 0.31.0
fuels versions
--------------
forc : 0.64.0
forc-wallet : 0.64.0
Default host: x86_64-unknown-linux-gnu
fuelup home: /home/chappie/.fuelup
Installed toolchains
--------------------
latest-x86_64-unknown-linux-gnu (default)
testnet-x86_64-unknown-linux-gnu
active toolchain
----------------
latest-x86_64-unknown-linux-gnu (default)
forc : 0.61.2
- forc-client
- forc-deploy : 0.61.2
- forc-run : 0.61.2
- forc-crypto : 0.61.2
- forc-debug : 0.61.2
- forc-doc : 0.61.2
- forc-fmt : 0.61.2
- forc-lsp : 0.61.2
- forc-tx : 0.61.2
- forc-wallet : 0.8.1
fuel-core : 0.31.0
fuel-core-keygen : 0.31.0
fuels versions
--------------
forc : 0.64.0
forc-wallet : 0.64.0
TS SDK:- 0.92.0
let me know if you need more details.
1 Like
Hi @chappie1998 , as stated in the documentation this error happens when a predicate fails to validate the input data. Could you share the line of code where instantiate the Predicate class? Also looking at address
you shared it seems to be an invalid b256
as it is one character short.
this is my full address, I missed e here.
const admin = "0x6b63804cfbf9856e68e5b6e7aef238dc8311ec55bec04df774003a2c96e0418e";
This is how I instantiate predicate class.
const createPredicate = async () => {
const wallet = await getWallet();
const predicate = PredicateAbi__factory.createInstance(
wallet.provider,
);
setRp(predicate);
return predicate;
};
Thanks for sharing @chappie1998 , I’m not seeing where the predicate has been funded, although I assume it is otherwise the error would be not enough funds
Unfortunately I haven’t been able to reproduce it locally as the following test is successful.
using launched = await launchTestNode();
const {
wallets: [wallet],
provider,
} = launched;
const predicate = PredicateTrueAbi__factory.createInstance(provider);
const address = '0x6b63804cfbf9856e68e5b6e7aef238dc8311ec55bec04df774003a2c96e0418e';
const baseAsset = '0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07';
// fund the predicate
const tx = await wallet.transfer(predicate.address, 200_000);
await tx.waitForResult();
const tx1 = await predicate.transfer(address, 50, baseAsset);
const result = await tx1.waitForResult();
expect(result.status).toBe('success');
Could you please share a link to an exact reproduction of the issue?
hey, may I know your fuelup show, TS SDK version?
@chappie1998 I used the same versions you stated here
Have you found success using other versions? You can explore the nightly toolchain