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?

3
  • In the smart contract, you write a (hard-coded) string literal, for example, "[email protected]"? Commented Nov 8, 2018 at 11:22
  • Or are you sending this value from the off-chain (Javascript) to the contract? Commented Nov 8, 2018 at 11:25
  • off-chain from user inputed value Commented Nov 8, 2018 at 11:28

1 Answer 1

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:

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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