Last active
May 27, 2019 06:21
-
-
Save Tschuck/e9c76e7005c56d7f7008f0d990799334 to your computer and use it in GitHub Desktop.
evan.network - api-blockchain-core sample browserified
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="./node_modules/@evan.network/api-blockchain-core-browserified/dist/bcc.js"></script> | |
<script src="./node_modules/@evan.network/smart-contracts-core-browserified/dist/compiled.js"></script> | |
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/index.min.js"></script> | |
<script src="https://cdn.jsdelivr.net/gh/ethereum/[email protected]/dist/web3.min.js"></script> | |
</head> | |
<script> | |
// ipfs configuration for evan.network testnet storage | |
const ipfsConfig = {host: 'ipfs.test.evan.network', port: '443', protocol: 'https'}; | |
// web3 provider config (currently evan.network testcore) | |
const web3Provider = 'wss://testcore.evan.network/ws'; | |
async function init() { | |
// initialize dependencies | |
const provider = new Web3.providers.WebsocketProvider( | |
web3Provider, | |
{ clientConfig: { keepalive: true, keepaliveInterval: 5000 } } | |
); | |
const web3 = new Web3(provider, { transactionConfirmationBlocks: 1, protocol: [ ] }); | |
const dfs = new bcc.Ipfs({ remoteNode: new IpfsApi(ipfsConfig), }); | |
const formattedContracts = { }; | |
Object.keys(smartcontracts).forEach((key) => { | |
const contractKey = (key.indexOf(':') !== -1) ? key.split(':')[1] : key; | |
formattedContracts[contractKey] = smartcontracts[key]; | |
}); | |
// create runtime | |
const runtime = await bcc.createDefaultRuntime(web3, dfs, { | |
mnemonic: 'leave best ship pulp hospital used damp decorate say mobile glance dilemma', | |
password: 'T1234567', | |
}, { | |
contracts: formattedContracts, | |
}); | |
console.log(runtime) | |
} | |
init(); | |
</script> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"dependencies": { | |
"@evan.network/api-blockchain-core-browserified": "^2.3.1", | |
"@evan.network/smart-contracts-core-browserified": "^2.1.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment