LoginSignup
0
0

More than 5 years have passed since last update.

jsdoでweb3.js その4

Posted at

概要

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");    
}




成果物

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0