# configure some parameters firstMASTER_ACCOUNT=# the master account to create MCS accountMCS_ACCOUNT=# MCS contract account to createCLIENT_ACCOUNT=# MAP light client contract accountMAP_BRIDGE_ADDRESS=# MCS contract address on MAP blockchainWNEAR_ACCOUNT=# "wrap.testnet" for testnet, "wrap.near" for mainnet NEAR_CHAIN_ID=# Near blockchain IDMCS_WASM_FILE=# path to the MCS contract wasm fileINIT_ARGS_MCS='{ "map_light_client": "'$CLIENT_ACCOUNT'", "map_bridge_address": "'$MAPO_BRIDGE_ADDRESS'", "wrapped_token": "'$WNEAR_ACCOUNT'", "near_chain_id": '$NEAR_CHAIN_ID' }'echo"creating MCS contract account"nearcreate-account $MCS_ACCOUNT --masterAccount $MASTER_ACCOUNT --initialBalance40echo"deploying mcs contract"neardeploy--accountId $MCS_ACCOUNT --wasmFile $MCS_WASM_FILEecho"initializing mcs contract"nearcall $MCS_ACCOUNT init"$INIT_ARGS_MCS"--accountId $MASTER_ACCOUNT --gas80000000000000
2. manage MCS token and transfer out MCS token
2.1 deploy MCS token and set metadata
MCS_TOKEN_NAME="usdt"# the MCS token you want to deployMCS_TOKEN=$MCS_TOKEN_NAME.$MCS_ACCOUNT # the MCS token contract addressDECIMALS=24# the MCS token decimalecho"deploying $MCS_TOKEN_NAME contract"near call $MCS_ACCOUNT deploy_mcs_token '{"address": "'$MCS_TOKEN_NAME'"}' --accountId $MASTER_ACCOUNT --deposit 10 --gas 80000000000000
echo"set decimal metadata of token $MCS_TOKEN to $DECIMALS"near call $MCS_ACCOUNT set_metadata '{"address": "'$$MCS_TOKEN'", "decimals": '$DECIMALS'}' --accountId $MCS_ACCOUNT --gas 80000000000000
2.2 add target chain for the MCS token to transfer to
TO_CHAIN=34434# target chain IDecho"adding $MCS_TOKEN to_chain $TO_CHAIN to mcs contract"near call $MCS_ACCOUNT add_mcs_token_to_chain '{"token": "'$MCS_TOKEN'", "to_chain": '$TO_CHAIN'}' --accountId $MCS_ACCOUNT
echo"getting mcs token list from mcs contract"nearview $MCS_ACCOUNT get_mcs_tokens'{}'
2.3 transfer out some amount (if someone has already transferred in some amount of the MCS token)
You can see the amount changes before and after the MCS token is transferred.
FROM=# sender address on NEAR blockchainTO="[46,120,72,116,221,179,44,215,151,93,104,86,91,80,148,18,165,181,25,244]" # the receiver address in bytes on target blockchain
AMOUNT=150000000000000000000000echo"before transfer out, get account $FROM balance of token $MCS_TOKEN"nearview $MCS_TOKEN ft_balance_of'{"account_id":"'$FROM'"}'echo"transfer out $AMOUNT $MCS_TOKEN token from $FROM to $TO on chain $TO_CHAIN"near call $MCS_ACCOUNT transfer_out_token '{"token":"'$MCS_TOKEN'", "to":'$TO', "amount":"'$AMOUNT'", "to_chain":'$TO_CHAIN'}' --accountId $FROM --gas 60000000000000
echo"after transfer out, get account $FROM balance of token $MCS_TOKEN"nearview $MCS_TOKEN ft_balance_of'{"account_id":"'$FROM'"}'
3. manage fungible token and transfer out fungible token
The difference between MCS tokens and fungible tokens is that the MCS contract has the privilege to mint/burn MCS tokens, but the fungible tokens are tokens deployed by others and already exists on NEAR blockchain.
3.1 add target chain for the fungible token to transfer to
You can see the amount changes before and after the fungible token is transferred.
FROM=# sender address on NEAR blockchainTO="[46,120,72,116,221,179,44,215,151,93,104,86,91,80,148,18,165,181,25,244]" # the receiver address in bytes on target blockchain
echo"before transfer out, get account $FROM balance of token $FT_TOKEN"nearview $FT_TOKEN ft_balance_of'{"account_id":"'$FROM'"}'echo"transfer out $AMOUNT $FT_TOKEN token from $FROM to $TO on chain $TO_CHAIN"near call $FT_TOKEN ft_transfer_call '{"receiver_id":"'$MCS_ACCOUNT'", "amount":"'$AMOUNT'", "memo": "", "msg": "{\"typ\": 0, \"to\": '$TO', \"to_chain\": '$TO_CHAIN'}"}' --accountId $FROM --depositYocto 1 --gas 60000000000000
echo"after transfer out, get account $FROM balance of token $FT_TOKEN"nearview $FT_TOKEN ft_balance_of'{"account_id":"'$FROM'"}'
4. manage native token (NEAR) and transfer out native token
4.1 add target chain for the native token to transfer to
TO_CHAIN=34434# target chain IDecho"adding native token to_chain $TO_CHAIN to mcs contract"nearcall $MCS_ACCOUNT add_native_to_chain'{"to_chain": '$TO_CHAIN'}'--accountId $MCS_ACCOUNT --gas150000000000000echo"getting native token list from mcs contract"nearview $MCS_ACCOUNT get_native_token_to_chains'{}'
4.2 transfer out some amount
You can see the amount changes before and after the native token is transferred.
FROM=# sender address on NEAR blockchainTO="[46,120,72,116,221,179,44,215,151,93,104,86,91,80,148,18,165,181,25,244]" # the receiver address in bytes on target blockchain
echo"before transfer out, get state of account $FROM"nearstate $FROMecho"transfer out $AMOUNT Yocto NEAR from $FROM to $TO on chain $TO_CHAIN"near call $MCS_ACCOUNT transfer_out_native '{ "to":'$TO', "to_chain": '$TO_CHAIN'}' --accountId $FROM --depositYocto $AMOUNT --gas 100000000000000
echo"after transfer out, get state of account $FROM"nearstate $FROM