今天调试手工采用node调用web3.js1.创建合约失败的过程:执行后contractaddress是null的代码:1.1下面的code取值从remix里面拷贝bytecodecode='0x608060405234801561001057600080fd5b5061025
今天调试手工采用node 调用web3.js
code = '0x608060405234801561001057600080fd5b5061025d806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80630acc083e1461004657806385d8284c14610076578063bcb4ab0e14610095575b600080fd5b610060600480360381019061005b9190610144565b6100b4565b60405161006d9190610180565b60405180910390f35b61007e6100ca565b60405161008c92919061019b565b60405180910390f35b61009d6100e5565b6040516100ab92919061019b565b60405180910390f35b60006001826100c391906101f3565b9050919050565b60008060016000546100dc91906101f3565b5a915091509091565b60008060016000546100f791906101f3565b6000819055506000545a915091509091565b600080fd5b6000819050919050565b6101218161010e565b811461012c57600080fd5b50565b60008135905061013e81610118565b92915050565b60006020828403121561015a57610159610109565b5b60006101688482850161012f565b91505092915050565b61017a8161010e565b82525050565b60006020820190506101956000830184610171565b92915050565b60006040820190506101b06000830185610171565b6101bd6020830184610171565b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006101fe8261010e565b91506102098361010e565b9250828201905080821115610221576102206101c4565b5b9291505056fea26469706673582212204f34bb1b403e445a9b5ec4ca4cbc912cb5614c210931fd57fe93ee7a3b68466264736f6c63430008110033'
npm init -y
npm i web3
node
url = 'http://localhost:8545'
{Web3} = require('web3')
web3 = new Web3(url)
accounts = await web3.eth.getAccounts()
zero ='0x0000000000000000000000000000000000000000'
tx = {from : accounts[0], to:zero, data: code}
receipt = await web3.eth.sendTransaction(tx)
tx.to 不赋值
url = 'http://localhost:8545'
{Web3} = require('web3')
web3 = new Web3(url)
accounts = await web3.eth.getAccounts()
//zero ='0x0000000000000000000000000000000000000000'
//web3 create transaction, do not set the tx.to zero address, zero address means detroy coin
// undefined tx.to means create transaction
tx = {from : accounts[0], data: code}
receipt = await web3.eth.sendTransaction(tx)
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!