jsdoでweb3.js その4
概要
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");
}
成果物
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");
}
以上。
Author And Source
この問題について(jsdoでweb3.js その4), 我々は、より多くの情報をここで見つけました https://qiita.com/ohisama@github/items/2498133ecd3bcb3bbf35著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .