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?

  • In the smart contract, you write a (hard-coded) string literal, for example, "me@gmail.com"? – goodvibration Nov 8 '18 at 11:22
  • Or are you sending this value from the off-chain (Javascript) to the contract? – goodvibration Nov 8 '18 at 11:25
  • off-chain from user inputed value – Raonak Islam Niloy Nov 8 '18 at 11:28

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:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.