Skip to content

Latest commit

 

History

History
232 lines (193 loc) · 7.87 KB

bts.md

File metadata and controls

232 lines (193 loc) · 7.87 KB

NEAR BTS Contract

Requirements

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

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

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

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

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

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

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

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

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
    Example
NEAR_ENV=testnet near call bts.iconbridge-6.testnet deposit --amount 10 --accountId dev-20211206025826-24100687319598
  1. Query Transfer Fee here
    Example
NEAR_ENV=testnet near view bts.iconbridge-6.testnet get_fee '{"coin_name": "btp-0x2.near-NEAR", "amount": "10000000000000000000000000"}'
  1. Transfer here
    Example
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
  1. Check locked balance for the transfered amount here
    Example
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
    Example
NEAR_ENV=testnet near view bts.iconbridge-6.testnet balance_of '{"account_id": "dev-20211206025826-24100687319598", "coin_name": "btp-0x2.near-NEAR"}'
  1. Withdraw here
    Example
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
  1. Check balance
    Example
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
    Example
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
  1. Query Transfer Fee here
    Example
NEAR_ENV=testnet near view bts.iconbridge-6.testnet get_fee '{"coin_name": "btp-0x2.icon-ICX", "amount": "10000000000000000000000000"}'
  1. Transfer here
    Example
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
  1. Check locked Balance for the transfered amount here
    Example
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
    Example
NEAR_ENV=testnet near view bts.iconbridge-6.testnet balance_of '{"account_id": "dev-20211206025826-24100687319598", "coin_name": "btp-0x2.icon-ICX"}'
  1. Withdraw here
    Example
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
  1. Check balance
    Example
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
    Example
NEAR_ENV=testnet near view bts.iconbridge-6.testnet refundable_balance_of '{"account_id": "dev-20211206025826-24100687319598", "coin_name": "btp-0x2.icon-ICX"}'
  1. Reclaim
    Example
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