Open bitcoinmeetups opened 2 years ago
Please provide steps to reproduce.
All good here
Ok, here's an example. I use this simple contract:
pragma solidity ^0.8.17; contract SolidityTest { constructor() public{ } function getResult() public view returns(uint){ uint a = 1; uint b = 2; uint result = a + b; return result; } }
Then I compile it with solcjs --bin test2.sol and get the binary in hex:
608060405234801561001057600080fd5b5061012d806100206000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063de29278914602d575b600080fd5b60336047565b604051603e91906082565b60405180910390f35b60008060019050600060029050600081836060919060ca565b905080935050505090565b6000819050919050565b607c81606b565b82525050565b6000602082019050609560008301846075565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600060d382606b565b915060dc83606b565b925082820190508082111560f15760f0609b565b5b9291505056fea2646970667358221220247c0a7e51d5e7d5ca2e58d433e6055a49cb1c736150c736acd5ee0a8f8bf4ce64736f6c63430008110033
Then I try to deploy it with:
web3 contract deploy test2.bin
And the outcome is:
ERROR: Error deploying contract: cannot decode contract data: hex string without 0x prefix
Please advise.
Add 0x to the start of the bin?
On Mon, Nov 21, 2022, 8:42 AM bitcoinmeetups.org @.***> wrote:
Ok, here's an example. I use this simple contract:
608060405234801561001057600080fd5b5061012d806100206000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063de29278914602d575b600080fd5b60336047565b604051603e91906082565b60405180910390f35b60008060019050600060029050600081836060919060ca565b905080935050505090565b6000819050919050565b607c81606b565b82525050565b6000602082019050609560008301846075565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600060d382606b565b915060dc83606b565b925082820190508082111560f15760f0609b565b5b9291505056fea2646970667358221220247c0a7e51d5e7d5ca2e58d433e6055a49cb1c736150c736acd5ee0a8f8bf4ce64736f6c63430008110033
Then I try to deploy it with:
web3 contract deploy test2.bin
And the outcome is:
ERROR: Error deploying contract: cannot decode contract data: hex string without 0x prefix
Please advise.
— Reply to this email directly, view it on GitHub https://github.com/gochain/web3/issues/236#issuecomment-1322084291, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAASQMVIBKFQJO6SAA4R5IDWJN33TANCNFSM5HYRXAKA . You are receiving this because you commented.Message ID: @.***>
That renders this error message instead: cannot decode contract data: invalid hex string.
Oh, you probably don't have WEB3_PRIVATE_KEY
set.
I do and it starts with 0x.
-------- Original Message -------- On Nov 23, 2022, 02:50, Travis Reeder wrote:
Oh, you probably don't have WEB3_PRIVATE_KEY set.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
Try following these instructions here: https://github.com/nuqtah/contracts exactly, might help.
So I still haven't solved this. Coming back to this again. Tried to change rpc. Same result. Tried to change private key. Same result. Tried to add 0x to private key. Same result. Do you have the -legacy flag?
I guess not. Tried with -legacy and same result. Any advice? You coded this error message so you might know better than me how I should respond to it.
If it works for you with a simple bin file, maybe you could post the bin file here and I can test it on my side. If that works then the issue is probably with the RPC or the address.
Can you be sure there's no new lines or anything in your bin? I have this in one of our automated scripts that removes ending new line.
perl -pi -e 'chomp if eof' ./contracts/Domain.bin
60806040523480156200001157600080fd5b50604051620015893803806200158983398181016040528101906200003791906200029d565b83600090805190602001906200004f92919062000141565b5082600190805190602001906200006892919062000141565b5081600260006101000a81548160ff021916908360ff1602179055508060038190555080600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503373ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516200012f91906200035e565b60405180910390a3505050506200054a565b8280546200014f9062000427565b90600052602060002090601f016020900481019282620001735760008555620001bf565b82601f106200018e57805160ff1916838001178555620001bf565b82800160010185558215620001bf579182015b82811115620001be578251825591602001919060010190620001a1565b5b509050620001ce9190620001d2565b5090565b5b80821115620001ed576000816000905550600101620001d3565b5090565b6000620002086200020284620003a4565b6200037b565b905082815260208101848484011115620002275762000226620004f6565b5b62000234848285620003f1565b509392505050565b600082601f830112620002545762000253620004f1565b5b815162000266848260208601620001f1565b91505092915050565b600081519050620002808162000516565b92915050565b600081519050620002978162000530565b92915050565b60008060008060808587031215620002ba57620002b962000500565b5b600085015167ffffffffffffffff811115620002db57620002da620004fb565b5b620002e9878288016200023c565b945050602085015167ffffffffffffffff8111156200030d576200030c620004fb565b5b6200031b878288016200023c565b93505060406200032e8782880162000286565b925050606062000341878288016200026f565b91505092959194509250565b6200035881620003da565b82525050565b60006020820190506200037560008301846200034d565b92915050565b6000620003876200039a565b90506200039582826200045d565b919050565b6000604051905090565b600067ffffffffffffffff821115620003c257620003c1620004c2565b5b620003cd8262000505565b9050602081019050919050565b6000819050919050565b600060ff82169050919050565b60005b8381101562000411578082015181840152602081019050620003f4565b8381111562000421576000848401525b50505050565b600060028204905060018216806200044057607f821691505b6020821081141562000457576200045662000493565b5b50919050565b620004688262000505565b810181811067ffffffffffffffff821117156200048a5762000489620004c2565b5b80604052505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b6200052181620003da565b81146200052d57600080fd5b50565b6200053b81620003e4565b81146200054757600080fd5b50565b61102f806200055a6000396000f3fe608060405234801561001057600080fd5b50600436106100935760003560e01c8063313ce56711610066578063313ce5671461013457806370a082311461015257806395d89b4114610182578063a9059cbb146101a0578063dd62ed3e146101d057610093565b806306fdde0314610098578063095ea7b3146100b657806318160ddd146100e657806323b872dd14610104575b600080fd5b6100a0610200565b6040516100ad9190610c7b565b60405180910390f35b6100d060048036038101906100cb9190610b2e565b61028e565b6040516100dd9190610c60565b60405180910390f35b6100ee6103ef565b6040516100fb9190610d1d565b60405180910390f35b61011e60048036038101906101199190610adb565b6103f5565b60405161012b9190610c60565b60405180910390f35b61013c610757565b6040516101499190610d38565b60405180910390f35b61016c60048036038101906101679190610a6e565b61076a565b6040516101799190610d1d565b60405180910390f35b61018a610782565b6040516101979190610c7b565b60405180910390f35b6101ba60048036038101906101b59190610b2e565b610810565b6040516101c79190610c60565b60405180910390f35b6101ea60048036038101906101e59190610a9b565b610a1f565b6040516101f79190610d1d565b60405180910390f35b6000805461020d90610e81565b80601f016020809104026020016040519081016040528092919081815260200182805461023990610e81565b80156102865780601f1061025b57610100808354040283529160200191610286565b820191906000526020600020905b81548152906001019060200180831161026957829003601f168201915b505050505081565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156102ff576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102f690610cfd565b60405180910390fd5b81600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040516103dd9190610d1d565b60405180910390a36001905092915050565b60035481565b600081600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610479576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161047090610cbd565b60405180910390fd5b81600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610538576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161052f90610c9d565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156105a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059f90610cdd565b60405180910390fd5b81600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546105f79190610dc5565b9250508190555081600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461064d9190610d6f565b9250508190555081600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546106e09190610dc5565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516107449190610d1d565b60405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60046020528060005260406000206000915090505481565b6001805461078f90610e81565b80601f01602080910402602001604051908101604052809291908181526020018280546107bb90610e81565b80156108085780601f106107dd57610100808354040283529160200191610808565b820191906000526020600020905b8154815290600101906020018083116107eb57829003601f168201915b505050505081565b600081600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610894576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161088b90610cbd565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610904576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108fb90610cdd565b60405180910390fd5b81600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546109539190610dc5565b9250508190555081600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546109a99190610d6f565b925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610a0d9190610d1d565b60405180910390a36001905092915050565b6005602052816000526040600020602052806000526040600020600091509150505481565b600081359050610a5381610fcb565b92915050565b600081359050610a6881610fe2565b92915050565b600060208284031215610a8457610a83610f11565b5b6000610a9284828501610a44565b91505092915050565b60008060408385031215610ab257610ab1610f11565b5b6000610ac085828601610a44565b9250506020610ad185828601610a44565b9150509250929050565b600080600060608486031215610af457610af3610f11565b5b6000610b0286828701610a44565b9350506020610b1386828701610a44565b9250506040610b2486828701610a59565b9150509250925092565b60008060408385031215610b4557610b44610f11565b5b6000610b5385828601610a44565b9250506020610b6485828601610a59565b9150509250929050565b610b7781610e0b565b82525050565b6000610b8882610d53565b610b928185610d5e565b9350610ba2818560208601610e4e565b610bab81610f16565b840191505092915050565b6000610bc3601683610d5e565b9150610bce82610f27565b602082019050919050565b6000610be6601483610d5e565b9150610bf182610f50565b602082019050919050565b6000610c09601183610d5e565b9150610c1482610f79565b602082019050919050565b6000610c2c600f83610d5e565b9150610c3782610fa2565b602082019050919050565b610c4b81610e37565b82525050565b610c5a81610e41565b82525050565b6000602082019050610c756000830184610b6e565b92915050565b60006020820190508181036000830152610c958184610b7d565b905092915050565b60006020820190508181036000830152610cb681610bb6565b9050919050565b60006020820190508181036000830152610cd681610bd9565b9050919050565b60006020820190508181036000830152610cf681610bfc565b9050919050565b60006020820190508181036000830152610d1681610c1f565b9050919050565b6000602082019050610d326000830184610c42565b92915050565b6000602082019050610d4d6000830184610c51565b92915050565b600081519050919050565b600082825260208201905092915050565b6000610d7a82610e37565b9150610d8583610e37565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115610dba57610db9610eb3565b5b828201905092915050565b6000610dd082610e37565b9150610ddb83610e37565b925082821015610dee57610ded610eb3565b5b828203905092915050565b6000610e0482610e17565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b83811015610e6c578082015181840152602081019050610e51565b83811115610e7b576000848401525b50505050565b60006002820490506001821680610e9957607f821691505b60208210811415610ead57610eac610ee2565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600080fd5b6000601f19601f8301169050919050565b7f496e73756666696369656e7420616c6c6f77616e636500000000000000000000600082015250565b7f496e73756666696369656e742062616c616e6365000000000000000000000000600082015250565b7f496e76616c696420726563697069656e74000000000000000000000000000000600082015250565b7f496e76616c6964207370656e6465720000000000000000000000000000000000600082015250565b610fd481610df9565b8114610fdf57600080fd5b50565b610feb81610e37565b8114610ff657600080fd5b5056fea2646970667358221220b49042e485856b65782da6
Same error message. Are you able to deploy the bin file above?
Hi,
When I try to deploy ERC-721 contracts (templates) I often get this error message. Any idea why?
ERROR: Error deploying contract: cannot decode contract data: hex string without 0x prefix