Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AbstractFruitFactory/fd37174feea242f36f271aaeed645e6d to your computer and use it in GitHub Desktop.
Save AbstractFruitFactory/fd37174feea242f36f271aaeed645e6d to your computer and use it in GitHub Desktop.
<script>
var zippieprovider = require('vault-web3-provider')
var vault = require('vault-api')
var vaultSecp256k1 = require('vault-api/src/secp256k1.js')
var Web3 = require('web3');
export default {
name: 'dashboard',
data() {
return {
}
},
beforeCreate: function() {
var opts = {}
if (location.hash.startsWith('#zippie-vault=')) {
opts = {
'vaultURL': location.hash.slice('#zippie-vault='.length)
}
}
vault.init(opts).then((result) => {
console.log('got inited:')
console.log(result)
var provider = zippieprovider.init(vault, vaultSecp256k1, {
network: 'kovan'
})
zippieprovider.addAccount('m/0').then((addy) => {
console.log(addy)
var web3 = new Web3(provider)
web3.eth.getAccounts().then((accounts) => {
console.log('accounts:')
console.log(accounts)
web3.eth.sendTransaction({
from: accounts[0],
gasPrice: "2000000000",
gas: "21000",
to: '0x21ef24ffb2116f44e7918a80cea4f52a2ea72b17',
value: "1",
data: ""
}).once('transactionHash', function(hash) {
console.log('transaction ' + hash)
})
.once('receipt', function(receipt) {
console.log('receipt ' + receipt)
})
.on('confirmation', function(confirmationNumber, receipt) {
console.log('confirmation ' + confirmationNumber + " " + receipt)
})
.on('error', console.error)
})
})
}, (error) => {
console.log('encountered error: ')
if (error.error === 'launch') {
vault.launch(error.launch)
}
console.log(error)
})
},
methods: {
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment