adsick / rust-ft-raffle

Rust smart contract that receives fungible tokens using transfer-and-call, giving raffle tickets

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

To build smart contracts

./build.sh

To deploy smart contracts

. ./deploy.sh

additional dot is required for running shell script in current session, so that all required parameters will be initialized correctly

Alice trying to buy tickets, sending ft_transfer_call to prize ft contract:

near call $prize ft_transfer_call '{"receiver_id": "'$raffle'", "amount": "6","msg":"buy_ticket"}' --accountId alice.$prize --amount 0.000000000000000000000001 --gas 200000000000000

Bob trying to buy tickets, sending ft_transfer_call to prize ft contract:

near call $prize ft_transfer_call '{"receiver_id": "'$raffle'", "amount": "6","msg":"buy_ticket"}' --accountId bob.$prize --amount 0.000000000000000000000001 --gas 200000000000000

Check balance of alice

near view $prize ft_balance_of '{"account_id": "'alice.$prize'"}'

Check balance of bob

near view $prize ft_balance_of '{"account_id": "'bob.$prize'"}'

Available tickets

near view $raffle total_tickets 

Reset: will recreate all tickets:

near call $raffle reset --accountId $raffle

About

Rust smart contract that receives fungible tokens using transfer-and-call, giving raffle tickets


Languages

Language:Rust 86.8%Language:Shell 13.2%