Skip to content

Instantly share code, notes, and snippets.

@rib3ye
Last active April 2, 2018 22:13
Show Gist options
  • Save rib3ye/b1fb89fc561bcaa1afce893f4786f641 to your computer and use it in GitHub Desktop.
Save rib3ye/b1fb89fc561bcaa1afce893f4786f641 to your computer and use it in GitHub Desktop.
A Sublime Text autocomplete snippet for creating a web3 instance
<snippet>
<content>
window.addEventListener('load', function() {
if (typeof web3 !== 'undefined') {
web3 = new Web3(web.currentProvider);
} else {
web3 = new Web3(new Web3.providers.HttpProvider("${1:http://127.0.0.1:7545}")); //Ganache Default
}
web3.eth.defaultAccount = web3.eth.accounts[0];
var ${2:ContractName} = web3.eth.contract(${3:abi});
var ${4:ContractObj} = ${2:ContractName}.at('${5:contactAddress}');
console.log(${4:ContractObj});
}
</content>
<tabTrigger>web3</tabTrigger>
</snippet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment