区块链中一个投票demo。在执行migrate命令部署合约时出错。
解决方法:把[“Nick”, “Rama”, “Jose”]修改为[“Nick”, “Rama”, “Jose”].map(x => web3.utils.asciiToHex(x))
原文https://medium.com/@betselothailu/thank-you-for-the-great-tutorial-6e0114b1d944
可能要弄个梯子。
下面是那个人的回复:
Thank you for the great tutorial.
If the migration step ( truffle migrate — network ganache) gives the following error:
“Voting” — invalid bytes32 value (arg=”candidateNames”, coderType=”bytes32", value=”Nick”).
Then
open “migrations/2_deploy_contracts.js” and replace [“Nick”, “Rama”, “Jose”] with [“Nick”, “Rama”, “Jose”].map(x => web3.utils.asciiToHex(x)) (Truffle v5.0.19)
The strings need to be replaced with their hex equivalents.