2

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 ?

Retr0
  • 21
  • 1

1 Answers1

2

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>);