Merge pull request #1 from alexvandesande/gh-pages

added geth deploy instructions
pull/1/head
chriseth 9 years ago
commit 2f0114832c
  1. 48
      index.html
  2. 2
      stylesheets/styles.css

@ -56,9 +56,19 @@ body {
width: 18ex;
display: inline-block;
}
strong.col1 {
top: -10px;
position: relative;
margin-bottom: 5px;
}
.col2 {
width: 60ex;
}
textarea.col2 {
height: 20px;
border-color: #bebebe;
margin-bottom: 5px;
}
.runButton {
width: 30ex;
text-align: left;
@ -199,6 +209,36 @@ var detailsOpen = {};
var renderError = function(message) {
$('#output').empty().append($('<pre></pre>').text(message));
};
var gethDeploy = function(contractName, interface, bytecode){
var code = "";
var funABI = getConstructorInterface($.parseJSON(interface));
$.each(funABI.inputs, function(i, inp) {
code += "var "+inp.name+" = /* var of type " + inp.type + " here */ ;\n";
});
code += "\nvar "+contractName+"Contract = web3.eth.contract("+interface.replace("\n","")+");"
+"\nvar "+contractName+" = "+contractName+"Contract.new(";
$.each(funABI.inputs, function(i, inp) {
code += "\n "+inp.name+",";
});
code += "\n {"+
"\n from: web3.eth.accounts[0], "+
"\n data: '"+bytecode+"', "+
"\n gas: 1000000"+
"\n }, function(e, contract){"+
"\n if (typeof contract.address != 'undefined') {"+
"\n console.log(e, contract);"+
"\n console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);" +
"\n }})";
return code;
}
var renderContracts = function(data, source) {
$('#output').empty();
for (var contractName in data.contracts) {
@ -209,7 +249,7 @@ var renderContracts = function(data, source) {
.append($('<div/>').text((contract.bytecode.length / 2) + ' bytes'))
.append(tableRow('Bytecode', contract.bytecode))
.append(tableRow('Interface', contract['interface']))
.append(tableRow('Solidity Interface', contract.solidity_interface))
.append(textRow('Geth deploy', gethDeploy(contractName.toLowerCase(),contract['interface'],contract.bytecode)))
.append(getDetails(contract, source, contractName));
$('#output').append(contractOutput);
}
@ -219,9 +259,15 @@ var tableRow = function(description, data) {
.append($('<span class="col1">').text(description))
.append($('<input readonly="readonly" class="col2">').val(data));
};
var textRow = function(description, data) {
return $('<div/>')
.append($('<strong class="col1">').text(description))
.append($('<textarea class="col2" onclick="this.select()">'+data+"</textarea>"));
};
var getDetails = function(contract, source, contractName) {
var button = $('<button>Details</button>');
var details = $('<div style="display: none;"/>')
.append(tableRow('Solidity Interface', contract.solidity_interface))
.append(tableRow('Opcodes', contract.opcodes));
var funHashes = '';
for (var fun in contract.functionHashes)

@ -1,4 +1,4 @@
@import url(https://fonts.googleapis.com/css?family=Lato:300italic,700italic,300,700);
/*@import url(https://fonts.googleapis.com/css?family=Lato:300italic,700italic,300,700);*/
body {
padding:50px;

Loading…
Cancel
Save