i'm quite struggling understanding how we can deposit and withdraw funds from smart contract on NEAR blockchain.
I'm currently using near-sdk-as with AssemblyScript. According to documentation I do have the ContractPromiseBatch.create(recipient).transfert(amount)
But how can we lock funds into the smart contract and withdraw it from allowed accounts ?
When you call your method with --amount <some amount here>
you have deposited these amounts to your contract balance. For example:
near call $CONTRACT add '{"url":"http://EXAPMLE.com", "title":"hello world"}' --accountId $AUTHOR --amount 3 //this is 3 NEARS you deposit to contract balance
When you want to send an amount from your contract balance to another person's balance you can use the contractPromiseBatch
API as follows:
const toAnotherPerson = ContractPromiseBatch.create("anotherPerson.testnet");
toAnotherPerson.transfer(<some amount here>);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.