ICX Transfer
For transfering a ICX to a particular wallet address or contract address we will make a transaction using TransactionBuilder()
Here we will be using this to transfer 99 ICX from our deployer wallet to our dice SCORE.
If you don't have enough ICX in your wallet then the transfer will fail. Use ibriz-faucet for getting ICX.
Also use deployer wallet only to make the transfer because fallback method of Dice SCORE only accepts incoming plain ICX from its owner
Execute the cell using Ctrl + Enter to transfer ICX to Dice SCORE.
1
transaction = TransactionBuilder()\
2
.from_(deployer_wallet.get_address())\
3
.to(<YOUR_SCORE_ADDRESS>)\
4
.nid(NID)\
5
.nonce(100)\
6
.value(50*10**18)\
7
.build()
8
9
estimate_step = icon_service.estimate_step(transaction)
10
step_limit = estimate_step + 100000
11
# Returns the signed transaction object having a signature
12
signed_transaction = SignedTransaction(transaction, caller_wallet,step_limit)
13
14
# Reads params to transfer to nodes
15
print(signed_transaction.signed_transaction_dict)
16
17
# Sends the transaction
18
tx_hash = icon_service.send_transaction(signed_transaction)
19
20
@retry(JSONRPCException, tries=10, delay=1, back_off=2)
21
def get_tx_result(_tx_hash):
22
tx_result = icon_service.get_transaction_result(_tx_hash)
23
return tx_result
24
25
get_tx_result(tx_hash)
Copied!
Execute the cell to get balance of Dice SCORE after transfer
1
balance = icon_service.get_balance(<YOUR_SCORE_ADDRESS>)
2
print(balance)
Copied!
Last modified 1yr ago
Copy link