Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add BTS API and commands for NEAR #502

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
177 changes: 177 additions & 0 deletions doc/near/bts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
## Requirements

* **NEAR CLI**
The NEAR [Command Line Interface (CLI)](https://github.com/near/near-cli) is a tool that enables to interact with the NEAR network directly from the shell. Under the hood, NEAR CLI utilizes the NEAR [JavaScript API](https://github.com/near/near-api-js)


#### Installation
```console
npm install -g near-cli
```
* **NEAR Wallet**
- Testnet: https://wallet.testnet.near.org/
- Mainnet: https://wallet.near.org/

* **Authorize CLI**
```console
near login
```
## API

### Balance

#### Usable Balance
**Method**
- balance_of

| Parameters | Type | Info |
|:---------|:--------|:--------|
| account_id | string | should be a valid account id |
| coin_name | string | |

**CLI Command**
```console
NEAR_ENV=testnet near view <BTS> balance_of '{"account_id": "<ACCOUNT ID>", "coin_name": "<Coin Name>"}'
```

#### Refundable Balance
**Method**
- refundable_balance_of

| Parameters | Type | Info |
|:---------|:--------|:--------|
| account_id | string | should be a valid account id |
| coin_name | string | |

**CLI Command**
```console
NEAR_ENV=testnet near view <BTS> refundable_balance_of '{"account_id": "<ACCOUNT ID>", "coin_name": "<Coin Name>"}'
```

#### Locked Balance
**Method**
- locked_balance_of

| Parameters | Type | Info |
|:---------|:--------|:--------|
| account_id | string | should be a valid account id |
| coin_name | string | |

**CLI Command**
```console
NEAR_ENV=testnet near view <BTS> locked_balance_of '{"account_id": "<ACCOUNT ID>", "coin_name": "<Coin Name>"}'
```

### Deposit

#### Deposit NEAR to BTS
**Method**
- deposit

**CLI Command**
```console
NEAR_ENV=testnet near call <BTS> deposit --amount <AMOUNT in NEAR> --accountId <ACCOUNT ID>
```
#### Deposit Cross-Chain Native Coin to BTS
**Method**
- ft_transfer_call

| Parameters | Type | Info |
|:---------|:--------|:--------|
| receiver_id | string | should be a valid account id |
| amount | string | |
| msg | string | |

**CLI Command**
```console
NEAR_ENV=testnet near call <NEP141 Contract> ft_transfer_call '{"receiver_id": "<BTS>", "amount": "<AMOUNT>", "msg": ""}' --accountId <ACCOUNT ID> --amount <1 yoctoNEAR in highest Denomination ie 0.000000000000000000000001>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a description for what the input parameters are.

```

### Withdraw
**Method**
- withdraw

| Parameters | Type | Info |
|:---------|:--------|:--------|
| coin_name | string | |
| amount | string | |

**CLI Command**
```console
NEAR_ENV=testnet near call <BTS> withdraw '{"coin_name": "<COIN NAME>", "amount":"<Amount in lowest Denomination>"}' --amount <1 yoctoNEAR in highest Denomination ie 0.000000000000000000000001> --gas 300000000000000 --accountId <ACCOUNT ID>
```

### Fee

#### Get Fee
**Method**
- get_fee

| Parameters | Type | Info |
|:---------|:--------|:--------|
| coin_name | string | |
| amount | string | |

**CLI Command**
```console
NEAR_ENV=testnet near view <BTS> get_fee '{"coin_name": "<Coin Name>", "amount": "<Amount in lowest Denomination, For NEAR in yoctoNEAR ie 1 NEAR = 1^24 yoctoNEAR>"}'
```

### Transfer
**Method**
- transfer

| Parameters | Type | Info |
|:---------|:--------|:--------|
| coin_name | string | |
| destination | string | valid btp address |
| amount | string | |

**CLI Command**
```console
NEAR_ENV=testnet near call <BTS> transfer '{"coin_name": "<Coin Name>", "destination": "btp://<Network>/<Address>", "amount": "<Amount in lowest Denomination, For NEAR in yoctoNEAR ie 1 NEAR = 1^24 yoctoNEAR>"}' --gas 300000000000000 --accountId <ACCOUNT ID>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a description for what the input parameters are. For example, the user may not know what BTS is or what btp:///

is. I also don't see what the valid possible inputs are for btp:/// because there is no NEAR info in https://github.com/icon-project/icon-bridge/blob/main/docs/testnet_deployment.json

```


## Usage
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These usages are not clear enough how to use because there are input parameters with no examples of what those should be. Please add the real-world usage for these commands instead of linking to the CLI commands.


### Transfer NEAR to Cross-Chain
1. Deposit NEAR to BTS [here](#deposit-near-to-bts)
2. Query Transfer Fee [here] (#get-fee)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not correctly linking because there is a space between [here] and (#get-fee)

3. Transfer [here](#transfer)
4. Check locked balance for the transfered amount [here](#balance)

### Receiving NEAR from Cross-Chain
1. Check usable balance amount to withdraw [here](#balance)
2. Withdraw [here](#withdraw)
3. Check balance
```console
NEAR_ENV=testnet near state <ACCOUNT ID>
```

### Transfer Cross-Chain Native Coins to Cross-Chain
1. Deposit Cross-Chain Native Coin to BTS [here](#deposit-cross-chain-native-coin-to-bts)
2. Query Transfer Fee [here] (#get-fee)
3. Transfer [here](#transfer)
4. Check locked Balance for the transfered amount [here](#locked-balance)

### Receiving Cross-Chain from Cross-Chain
1. Check usable balance amount to withdraw [here](#usable-balance)
2. Withdraw [here](#withdraw)
3. Check balance
```console
NEAR_ENV=testnet near view <NEP141 Contract> ft_balance_of '{"account_id": "<ACCOUNT ID>"'
```

### Reclaiming Failed Transfer
1. Check refundable balance to reclaim [here](#refundable-balance)
2. Reclaim
```console
NEAR_ENV=testnet near call <BTS> reclaim '{"coin_name": "<Coin Name>", "amount":"<Amount in lowest Denomination>"}' --amount 0.000000000000000000000001 --gas 300000000000000 --accountId <ACCOUNT ID>
```

## Environment

- [Testnet](./testnet.md)


10 changes: 10 additions & 0 deletions doc/near/testnet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Testnet

### BTS
bts.iconbridge.testnet
### Registered Tokens

| Coin/Token|Coin Name| Network| Denomination| NEP141 Contract |
|:---------|:--------|:--------|:------------|:----------|
| NEAR | btp-0x1.near-NEAR | 0x1.near | 24 | N/A |
| ICX | btp-0x2.icon-ICX | 0x2.icon | 18 | btp-icx.bts.iconbridge.testnet |