概要
jsdoでweb3.jsやってみた。
デプロイしてみた。
写真
サンプルコード
var src0 = document.getElementById('src0');
var src1 = document.getElementById('src1');
var src2 = document.getElementById('src2');
var Web3 = require('web3');
var web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider('http://127.0.0.1:8545'));
function deploy() {
var bin = JSON.parse(src0.value);
var abi = JSON.parse(src1.value);
var bytecode = "0x" + bin.object;
var gasEstimate = web3.eth.estimateGas({
data: bytecode
});
alert(gasEstimate);
var TestContract = web3.eth.contract(abi);
alert(TestContract);
web3.personal.unlockAccount(web3.eth.coinbase, "password0");
alert("ok0");
TestContract.new({
from: web3.eth.coinbase,
data: bytecode,
gas: gasEstimate
});
alert("ok1");
}
成果物
以上。