Skip to content

Commit

Permalink
Merge pull request #8 from ghimire007/patch-8
Browse files Browse the repository at this point in the history
Update token-tx.md
  • Loading branch information
ghimire007 authored Sep 4, 2023
2 parents c97358f + 69dfb37 commit d94086d
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions docs/sdk/rust/promises/token-tx.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
sidebar_position: 2
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Sending $NEAR

You might want to send tokens from a contract for many reasons.
Expand Down Expand Up @@ -47,7 +50,29 @@ Most of this is boilerplate you're probably familiar with by now – imports, s

* Returning `Promise`: This allows NEAR Explorer, near-cli, near-api-js, and other tooling to correctly determine if a whole chain of transactions is successful. If your function does not return `Promise`, tools like near-cli will return immediately after your function call. And then even if the `transfer` fails, your function call will be considered successful. You can see an example of this behavior [here](https://github.com/near-examples/xcc-advanced).

Using near-cli, someone could invoke this function with a call like:
Using near-cli or near-cli-rs, someone could invoke this function with a call like:

<Tabs className="language-tabs" groupId="code-tabs">
<TabItem value="Near-CLI">


```bash
near call <contract> pay '{"amount": "1000000000000000000000000", "to": "example.near"}' --accountId benjiman.near
```



</TabItem>
<TabItem value="Near-CLI-rs">

```bash
near contract call-function as-transaction <contract> pay json-args '{"amount": "1000000000000000000000000", "to": "example.near"}' prepaid-gas '30 TeraGas' attached-deposit '0 NEAR' sign-as benjiman.near network-config testnet sign-with-keychain send
```



</TabItem>
</Tabs>


near call $CONTRACT pay '{"amount": "1000000000000000000000000", "to": "example.near"}' --accountId benjiman.near

0 comments on commit d94086d

Please sign in to comment.