How to send data to a smart contract function (Ethereum Blockchain)?


I am using ESP32 for interacting with the smart contract. I am facing issues while sending data to smart contract function. I am using the Ethereum library provided by Zerynth. I am using Contract class to call and send data.

Please help me out.


Hi @sushant662000 :slight_smile:

I am facing issues while sending data to smart contract function.

what issues are you referring to?

A pretty detailed example can be found in Zerynth Studio searching for “Dice Game”.

The contains some structure for defining the contract methods that you can later register ( and then call using our Ethereum library.


I am not able to provide arguments in tx method of contract class.
I want to provide arguments in smart contract function.
Can you provide me an example to show how to use tx method.
for eg. tx(‘function’, nonce, value, args=())
what to put in args.
Dice game example is not sending data to any function of smart contract its just sending the Ether. I want an example sending data to smart contract function.
Thank you for your help.


I have modified the Dice game smart contract. Now I am providing data to the functions in smart contract.
Here is the part of code,
jackpot =‘get’, rv=(256, int))
print(‘Current jackpot: %s’ %x)
#print(‘Betting %s Wei…’ % config.BET_AMOUNT)
nonce = eth.getTransactionCount(config.ADDRESS)
tx_hash = game.tx(‘set’, nonce, value=(0,ethereum.WEI), args=(1,1))
print(‘Your bet has been placed, and the transaction is now being mined.’)
print(‘Monitor your balance at to see if you won!’ % config.ADDRESS)
print(‘Reset your device to play again.’)

In this code I want to provide a single argument in args but its asking for a tuple. When provided single value in tuple eg. args=(1) then its giving error. The transaction hash is showing None i.e transaction is not done.


args=(1) is not a tuple but actually (1) is evaluated to 1 - basically it is equivalent to args=1.

Try using args=(1,), that’s the Python syntax for a single value tuple :slight_smile: