-
Notifications
You must be signed in to change notification settings - Fork 15
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
MuhammedIrfan
wants to merge
9
commits into
main
Choose a base branch
from
docs/429-document-explaining-the-workflow-of-cross-chain-transfer-from-near
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
919673c
add commands for interacting with bts using near cli
shreyasbhat0 25756f2
fix syntax
shreyasbhat0 f0a8995
fix syntax
shreyasbhat0 01a335a
Merge branch 'hugobyte/development' into docs/429-document-explaining…
MuhammedIrfan 0d1c41c
Update bts.md
MuhammedIrfan 85cbab8
fix formating
MuhammedIrfan 10c8f0f
add get fee method
MuhammedIrfan c588116
Merge branch 'main' into docs/429-document-explaining-the-workflow-of…
MuhammedIrfan 06f1c54
add description
MuhammedIrfan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,232 @@ | ||
# NEAR BTS Contract | ||
|
||
## 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 | Valid near account id | | ||
| coin_name | string | Name of coin | | ||
|
||
**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 | Valid near account id | | ||
| coin_name | string | Name of coin | | ||
|
||
**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 | Valid near account id | | ||
| coin_name | string | Name of coin | | ||
|
||
**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 | Valid near account id | | ||
| amount | string | Amount to deposit | | ||
| 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> | ||
``` | ||
|
||
### Withdraw | ||
**Method** | ||
- withdraw | ||
|
||
| Parameters | Type | Info | | ||
|:---------|:--------|:--------| | ||
| coin_name | string | Name of coin to withdraw | | ||
| amount | string | Amount to withdraw | | ||
|
||
**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 | Name of coin to transfer | | ||
| amount | string | Amount to transfer | | ||
|
||
**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 | Name of coin to transfer | | ||
| destination | string | BTP Address of destination | | ||
| amount | string | Amount to transfer | | ||
|
||
**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> | ||
``` | ||
|
||
|
||
## Usage | ||
|
||
### Transfer NEAR to Cross-Chain | ||
1. Deposit NEAR to BTS [here](#deposit-near-to-bts) | ||
**Example** | ||
```console | ||
NEAR_ENV=testnet near call bts.iconbridge-6.testnet deposit --amount 10 --accountId dev-20211206025826-24100687319598 | ||
``` | ||
2. Query Transfer Fee [here](#get-fee) | ||
**Example** | ||
```console | ||
NEAR_ENV=testnet near view bts.iconbridge-6.testnet get_fee '{"coin_name": "btp-0x2.near-NEAR", "amount": "10000000000000000000000000"}' | ||
``` | ||
3. Transfer [here](#transfer) | ||
**Example** | ||
```console | ||
NEAR_ENV=testnet near call bts.iconbridge-6.testnet transfer '{"coin_name": "btp-0x2.near-NEAR", "destination": "btp://0x2.icon/hx54d9ba221fbe8a475a8bf38c7d048675b5d7b85a", "amount": "10000000000000000000000000"}' --gas 300000000000000 --accountId dev-20211206025826-24100687319598 | ||
``` | ||
4. Check locked balance for the transfered amount [here](#balance) | ||
**Example** | ||
```console | ||
NEAR_ENV=testnet near view bts.iconbridge-6.testnet locked_balance_of '{"account_id": "dev-20211206025826-24100687319598", "coin_name": "btp-0x2.near-NEAR"}' | ||
``` | ||
|
||
### Receiving NEAR from Cross-Chain | ||
1. Check usable balance amount to withdraw [here](#balance) | ||
**Example** | ||
```console | ||
NEAR_ENV=testnet near view bts.iconbridge-6.testnet balance_of '{"account_id": "dev-20211206025826-24100687319598", "coin_name": "btp-0x2.near-NEAR"}' | ||
``` | ||
2. Withdraw [here](#withdraw) | ||
**Example** | ||
```console | ||
NEAR_ENV=testnet near call bts.iconbridge-6.testnet withdraw '{"coin_name": "btp-0x2.near-NEAR", "amount":"10000000000000000000000000"}' --amount 0.000000000000000000000001 --gas 300000000000000 --accountId dev-20211206025826-24100687319598 | ||
``` | ||
3. Check balance | ||
**Example** | ||
```console | ||
NEAR_ENV=testnet near state dev-20211206025826-24100687319598 | ||
``` | ||
|
||
### Transfer Cross-Chain Native Coins to Cross-Chain | ||
1. Deposit Cross-Chain Native Coin to BTS [here](#deposit-cross-chain-native-coin-to-bts) | ||
**Example** | ||
```console | ||
NEAR_ENV=testnet near call btp-icx.bts.iconbridge-6.testnet ft_transfer_call '{"receiver_id": "bts.iconbridge-6.testnet", "amount": "10000000000000000000000000", "msg": ""}' --accountId dev-20211206025826-24100687319598 --amount 0.000000000000000000000001 | ||
``` | ||
2. Query Transfer Fee [here](#get-fee) | ||
**Example** | ||
```console | ||
NEAR_ENV=testnet near view bts.iconbridge-6.testnet get_fee '{"coin_name": "btp-0x2.icon-ICX", "amount": "10000000000000000000000000"}' | ||
``` | ||
3. Transfer [here](#transfer) | ||
**Example** | ||
```console | ||
NEAR_ENV=testnet near call bts.iconbridge-6.testnet transfer '{"coin_name": "btp-0x2.icon-ICX", "destination": "btp://0x2.icon/hx54d9ba221fbe8a475a8bf38c7d048675b5d7b85a", "amount": "10000000000000000000000000"}' --gas 300000000000000 --accountId dev-20211206025826-24100687319598 | ||
``` | ||
4. Check locked Balance for the transfered amount [here](#locked-balance) | ||
**Example** | ||
```console | ||
NEAR_ENV=testnet near view bts.iconbridge-6.testnet locked_balance_of '{"account_id": "dev-20211206025826-24100687319598", "coin_name": "btp-0x2.icon-ICX"}' | ||
``` | ||
|
||
### Receiving Cross-Chain from Cross-Chain | ||
1. Check usable balance amount to withdraw [here](#usable-balance) | ||
**Example** | ||
```console | ||
NEAR_ENV=testnet near view bts.iconbridge-6.testnet balance_of '{"account_id": "dev-20211206025826-24100687319598", "coin_name": "btp-0x2.icon-ICX"}' | ||
``` | ||
2. Withdraw [here](#withdraw) | ||
**Example** | ||
```console | ||
NEAR_ENV=testnet near call bts.iconbridge-6.testnet withdraw '{"coin_name": "btp-0x2.icon-ICX", "amount":"10000000000000000000000000"}' --amount 0.000000000000000000000001 --gas 300000000000000 --accountId dev-20211206025826-24100687319598 | ||
``` | ||
3. Check balance | ||
**Example** | ||
```console | ||
NEAR_ENV=testnet near view btp-icx.bts.iconbridge-6.testnet ft_balance_of '{"account_id": "dev-20211206025826-24100687319598"' | ||
``` | ||
|
||
### Reclaiming Failed Transfer | ||
1. Check refundable balance to reclaim [here](#refundable-balance) | ||
**Example** | ||
```console | ||
NEAR_ENV=testnet near view bts.iconbridge-6.testnet refundable_balance_of '{"account_id": "dev-20211206025826-24100687319598", "coin_name": "btp-0x2.icon-ICX"}' | ||
``` | ||
2. Reclaim | ||
**Example** | ||
```console | ||
NEAR_ENV=testnet near call bts.iconbridge-6.testnet reclaim '{"coin_name": "btp-0x2.icon-ICX", "amount":"10000000000000000000000000"}' --amount 0.000000000000000000000001 --gas 300000000000000 --accountId dev-20211206025826-24100687319598 | ||
``` | ||
|
||
## Environment | ||
|
||
- [Testnet](./testnet.md) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
## Testnet | ||
|
||
### BTS | ||
bts.iconbridge-6.testnet | ||
### Registered Tokens | ||
|
||
| Coin/Token|Coin Name| Network| Denomination| NEP141 Contract | | ||
|:---------|:--------|:--------|:------------|:----------| | ||
| NEAR | btp-0x2.near-NEAR | 0x2.near | 24 | N/A | | ||
| ICX | btp-0x2.icon-ICX | 0x2.icon | 18 | btp-icx.bts.iconbridge-6.testnet | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,55 @@ | ||
{ | ||
"networks": { | ||
"icon": { | ||
"uri": "https://lisbon.net.solidwallet.io/api/v3/icon_dex", | ||
"network_id": "0x2", | ||
"btp_network_id": "0x2.icon", | ||
"block_height": 11273953 | ||
}, | ||
"bsc": { | ||
"uri": "https://data-seed-prebsc-1-s1.binance.org:8545", | ||
"network_id": "0x61", | ||
"btp_network_id": "0x61.bsc", | ||
"block_height": 21985565 | ||
} | ||
}, | ||
"contracts": { | ||
"icon": { | ||
"sICX": "cxc7b869d97a567044a2a5acea180ecd9071cd20b0", | ||
"bnUSD": "cxcadcaf77d8e46089fd3d98fcf71eabee1700f148", | ||
"BNB": "cx55b835590d43af7bf6f5be3c3d50982264d24e5d", | ||
"BUSD": "cx39a7fefbe48ca7984e036abb1fab16f25fa641bb", | ||
"USDT": "cxdb7e556a7fd5441bead5d7c5403d414223d51132", | ||
"USDC": "cxf021731307d9f382935ac4bda81ee03946e1e4bd", | ||
"BTCB": "cx7c1ef7b631a64e33e35565b81e669a05cdd0d968", | ||
"ETH": "cx4663c5f1d955207c5718aedb11ff029f08b50036", | ||
"bmc": "cx053b96e2de3b9e6fc06db7b390d96ebf5fe82892", | ||
"bts": "cxa843db0a27750230559f997bafaeb7f8739afc81" | ||
}, | ||
"bsc": { | ||
"BUSD": "0x119344c4354AcD401Ffb7Ed58e2B03fBA6759a87", | ||
"USDT": "0x51C59A4453e26c1DC46E282cbC6FFDD72ceC16DA", | ||
"USDC": "0x2f84D2Eeac14e2d02aaf00eB25801721D4233d19", | ||
"BTCB": "0xd5d707da717cf4771Ed995f16E976C711890F118", | ||
"ETH": "0xE3471f58314332502Be2B0681a66D674D98763D6", | ||
"ICX": "0x7d8c52A23FD7e3ca1342797baE7caF6d7b8036BA", | ||
"sICX": "0x0a7792fe75548b26b287871081Aa6b05f48D9e89", | ||
"bnUSD": "0xc0c1aA22F99bb6724dC4159C256A5989D90A659C", | ||
"BMCManagement": "0x5B9733113745F87A790321e2a84e73CbDa628B95", | ||
"BMCPeriphery": "0x853CceE29C20331DB18937E6bEdb8ab477ebe691", | ||
"BTSCore": "0x1a2aDf985D6c2700fdAf72A9c1e2b39e3B647F7e", | ||
"BTSPeriphery": "0x69555E113279b3d3805492a829DD765ED394A669" | ||
} | ||
} | ||
"networks": { | ||
"icon": { | ||
"uri": "https://lisbon.net.solidwallet.io/api/v3/icon_dex", | ||
"network_id": "0x2", | ||
"btp_network_id": "0x2.icon", | ||
"block_height": 11273953 | ||
}, | ||
"bsc": { | ||
"uri": "https://data-seed-prebsc-1-s1.binance.org:8545", | ||
"network_id": "0x61", | ||
"btp_network_id": "0x61.bsc", | ||
"block_height": 21985565 | ||
}, | ||
"near": { | ||
"uri": "https://rpc.testnet.near.org", | ||
"network_id": "0x2", | ||
"btp_network_id": "0x2.near", | ||
"block_height": 102880710 | ||
} | ||
}, | ||
"contracts": { | ||
"icon": { | ||
"sICX": "cxc7b869d97a567044a2a5acea180ecd9071cd20b0", | ||
"bnUSD": "cxcadcaf77d8e46089fd3d98fcf71eabee1700f148", | ||
"BNB": "cx55b835590d43af7bf6f5be3c3d50982264d24e5d", | ||
"BUSD": "cx39a7fefbe48ca7984e036abb1fab16f25fa641bb", | ||
"USDT": "cxdb7e556a7fd5441bead5d7c5403d414223d51132", | ||
"USDC": "cxf021731307d9f382935ac4bda81ee03946e1e4bd", | ||
"BTCB": "cx7c1ef7b631a64e33e35565b81e669a05cdd0d968", | ||
"ETH": "cx4663c5f1d955207c5718aedb11ff029f08b50036", | ||
"bmc": "cx053b96e2de3b9e6fc06db7b390d96ebf5fe82892", | ||
"bts": "cxa843db0a27750230559f997bafaeb7f8739afc81" | ||
}, | ||
"bsc": { | ||
"BUSD": "0x119344c4354AcD401Ffb7Ed58e2B03fBA6759a87", | ||
"USDT": "0x51C59A4453e26c1DC46E282cbC6FFDD72ceC16DA", | ||
"USDC": "0x2f84D2Eeac14e2d02aaf00eB25801721D4233d19", | ||
"BTCB": "0xd5d707da717cf4771Ed995f16E976C711890F118", | ||
"ETH": "0xE3471f58314332502Be2B0681a66D674D98763D6", | ||
"ICX": "0x7d8c52A23FD7e3ca1342797baE7caF6d7b8036BA", | ||
"sICX": "0x0a7792fe75548b26b287871081Aa6b05f48D9e89", | ||
"bnUSD": "0xc0c1aA22F99bb6724dC4159C256A5989D90A659C", | ||
"BMCManagement": "0x5B9733113745F87A790321e2a84e73CbDa628B95", | ||
"BMCPeriphery": "0x853CceE29C20331DB18937E6bEdb8ab477ebe691", | ||
"BTSCore": "0x1a2aDf985D6c2700fdAf72A9c1e2b39e3B647F7e", | ||
"BTSPeriphery": "0x69555E113279b3d3805492a829DD765ED394A669" | ||
}, | ||
"near": { | ||
"bmc":"7270a79be789d770f2de015047684e2806597eeee96ee3ca87b179c6399deaaf", | ||
"bts":"bts.iconbridge-6.testnet", | ||
"ICX":"btp-icx.bts.iconbridge-6.testnet" | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please move tokens above smart contract addresses to be consistent with icon and bsc, and add an equivalent contract for each of the tokens listed on icon and bsc that are not currently listed on near
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, where are the NEAR token addresses for the other networks?