Closed Enflow-io closed 6 months ago
Hi @Enflow-io thanks for your contact but we don't give support on github.
You can transfer a token to a contract by wrapping the contract hash into a Casper Key type. https://github.com/casper-ecosystem/cep18/blob/dev/tests/src/transfer.rs#L205-L221 . Casper Client CLI will let you do that.
With the js client you probably need to convert the contract hash to a byte array then to a key.
const convertHashStringToBuffer = (hashStr: string): Buffer => {
const hashHex = hashStr.startsWith("hash-") ? hashStr.slice(5) : hashStr;
return Buffer.from(hashHex, "hex");
};
....
// in the transfer request arguments
const runtimeArgs = RuntimeArgs.fromMap({});
if (contract_hash) {
CLValueBuilder.key(
CLValueBuilder.byteArray(convertHashStringToBuffer(contract_hash))
)
}
....
Please go on the Casper discord https://discord.com/invite/casperblockchain to get adequate support.
Regards
Hello!
Is it possible to keep some token on a smart contract balance? And how to implement such behaviour?