custom web3 endpoint

pull/1/head
d11e9 9 years ago
parent b8e6d45f1c
commit 48a5fccbf9
  1. 2
      assets/js/universal-dapp.js
  2. 16
      index.html

@ -22,7 +22,7 @@ function UniversalDApp (contracts, options) {
} else {
var host = options.host || "localhost";
var port = options.port || "8545";
var rpc_url = 'http://' + host + ':' + port;
var rpc_url = options.web3endpoint || ('http://' + host + ':' + port);
web3.setProvider( new web3.providers.HttpProvider( rpc_url ) );
}

@ -97,13 +97,18 @@
</div>
<div id="envView">
<span id="executionContext">
<label for="vm" title="Execution environment does not connect to any node, everything is local and in memory only.">
<label for="vm">
<input id="vm" type="radio" value="vm" checked name="executionContext">
JavaScript VM
<strong>JavaScript VM</strong>
<p>Execution environment does not connect to any node, everything is local and in memory only.</p>
</label>
<label for="web3" title="Execution environment connects to node at localhost, transactions will be sent to the network and can cause loss of money or worse!">
<label for="web3">
<input id="web3" type="radio" value="web3" name="executionContext">
Web3 Provider
<strong>Web3 Provider</strong>
<p>Execution environment connects to node at localhost, transactions will be sent to the network and can cause loss of money or worse!</p>
<label for="web3Endpoint">
<strong>Web3 Provider Endpoint</strong>: <input type="text" id="web3Endpoint" value="http://localhost:8545">
</label>
</label>
</span>
</div>
@ -222,12 +227,14 @@
var $vmToggle = $('#vm');
var $web3Toggle = $('#web3');
var $web3endpoint = $('#web3Endpoint');
var executionContext = 'vm';
$vmToggle.get(0).checked = true;
$vmToggle.on('change', executionContextChange );
$web3Toggle.on('change', executionContextChange );
$web3endpoint.on('change', compile );
function executionContextChange (ev) {
if (ev.target.value == 'web3' && !confirm("Are you sure you want to connect to a local ethereum node?") ) {
@ -752,6 +759,7 @@
removable: false,
getAddress: function(){ return $('#txorigin').val(); },
removable_instances: true,
web3endpoint: $('#web3Endpoint').val(),
renderOutputModifier: function(contractName, $contractOutput) {
var contract = data.contracts[contractName];
return $contractOutput

Loading…
Cancel
Save