1

I am going to set a email address from users and going to save it to ethereum network.

I kept email as bytes32 in smart contract and when I am sending the value to javascript i am getting always a same bytes . when i use to convert to ascii I am getting '@' everytime. what can be the reason?

1 Answers1

3

If you're on web3 v0.x, then:

  • Use web3.fromAscii before you send the string to the smart contract
  • Use web3.toAscii after you read the string from the smart contract

If you're on web3 v1.x, then:

goodvibration
  • 26,003
  • 5
  • 46
  • 86