I'm developing a Flutter application and used Dartez plugin to transfer token contracts from one wallet to another wallet.
The Dartez package has a function named sendContractInvocationOperation for this purpose.
I used this function in my project like this:
final token = TokenModel(...);
var server = '';
var keyStore = KeyStoreModel(
publicKey: 'edpk.....rrj',
secretKey: 'edsk.....yHH',
publicKeyHash: 'tz1.....hxy',
);
int amount = 10000; // just as sample
String withdrawalAddress = "tz1.....xyz";
var signer = await Dartez.createSigner(
Dartez.writeKeyWithHint(keyStore.secretKey, 'edsk'));
var contractAddress = ['KT1.....xMY'];
final parameters = token.isFA1
? '''(Pair "${keyStore.publicKeyHash}" (Pair "$withdrawalAddress" $amount))'''
: '''{Pair "${keyStore.publicKeyHash}" {Pair "$withdrawalAddress" (Pair $tokenId $amount)}}''';
final dynamic resultInvoke = await Dartez.sendContractInvocationOperation(
server,
signer as SoftSigner,
keyStore,
contractAddress,
[0],
customFee,
1000,
customFee,
['transfer'],
[parameters],
codeFormat: TezosParameterFormat.Michelson,
);
print("Operation groupID ===> $resultInvoke['operationGroupID']");
But the problem is when my token standard is "fa2" then the transaction failed with this error: please click here to see the error log
The above error was about the Crunch token, which is a token with the "fa2" standard.
I also checked the transfer function entypoints from here: CRUNCH entypoints and the transfer function is:
Json schema:
"schema:list:object": [
{
"from_:address": "address",
"txs:list:object": [
{
"to_:address": "address",
"token_id:nat": "nat",
"amount:nat": "nat"
}
]
}
]
Michelson type:
(list %transfer (pair (address %from_)
(list %txs (pair (address %to_) (pair (nat %token_id) (nat %amount))))))
As you see, it provides the function in Michelson type, but I'm not sure whether the parameters that I retrieved from this Michelson function and used inside "Dartez.sendContractInvocationOperation" function is the correct format or not.
Note: I don't understand the Michelson language and don't know the correct syntax.