Merge pull request #140 from axic/feature/provide-value

Support specifying a value for a transaction
pull/1/head
chriseth 9 years ago
commit 9e148f0fef
  1. 4
      assets/js/app.js
  2. 12
      assets/js/universal-dapp.js
  3. 4
      index.html

@ -672,6 +672,10 @@
vm: executionContext === 'vm',
removable: false,
getAddress: function(){ return $('#txorigin').val(); },
getValue: function(){
var comp = $('#value').val().split(' ');
return web3.toWei(comp[0], comp.slice(1).join(' '));
},
removable_instances: true,
renderOutputModifier: function(contractName, $contractOutput) {
var contract = data.contracts[contractName];

@ -431,7 +431,15 @@ UniversalDApp.prototype.runTx = function( data, args, cb) {
data = '0x' + data;
var gas = self.options.getGas ? self.options.getGas : 1000000;
var value = self.options.getValue ? self.options.getValue : 0;
var value = 0;
if (self.options.getValue) {
try {
value = self.options.getValue();
} catch (e) {
return cb(e);
}
}
if (!this.vm) {
var tx = {
@ -459,7 +467,7 @@ UniversalDApp.prototype.runTx = function( data, args, cb) {
gasPrice: 1,
gasLimit: 3000000000, //plenty
to: to,
value: value,
value: new this.BN(value, 10),
data: new Buffer(data.slice(2), 'hex')
});
tx.sign(account.privateKey);

@ -80,8 +80,8 @@
<div class="row hide">
<label for="gasPrice"><input type="number" id="gasPrice" value="0"> Gas Price</label>
</div>
<div class="row hide">
<label for="value"><input type="number" id="value" value="0"> Value</label>
<div class="row">
<label for="value"><input type="text" id="value" value="0"> Value (e.g. .7 ether or 5 wei, defaults to ether)</label>
</div>
</div>
<div id="settingsView">

Loading…
Cancel
Save