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
<!-- Continue with the App.vue --> | |
<script> | |
const operations = require('./operations.js') | |
const utils = require('./utils.js') | |
export default { | |
data() { | |
return { | |
myaddress: '0xa7a609b928c4eac077d0e5640f3fa650746c4fcf', | |
myamount: 0, |
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
<script> | |
methods: { | |
// ... add after refreshTokenBalance() | |
transfer () { // Confrim and send out a transfer. | |
const evmAmount = utils.humanToEVM(this.toamount.toString(), 18) | |
operations.transferToken(this.contract, this.myaddress, this.toaddress, evmAmount, this.toamount, 'VTHO') | |
.then(result => {alert('success!')}) | |
.catch(e => {alert('failed!')}) | |
} | |
} |
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
<template> | |
<div id="app"> | |
<div> | |
<b-card style="max-width: 30rem;" :header="myaddress"> | |
<p>{{myamount}} <span class="text-primary">VTHO</span></p> | |
<b-form-group label="To Address:" label-for="toaddress"> | |
<b-form-input id="toaddress" v-model.trim="toaddress"></b-form-input> | |
</b-form-group> |
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
<template> | |
<div id="app"> | |
<div> | |
<b-card style="max-width: 30rem;" :header="myaddress"> | |
<p>{{myamount}} <span class="text-primary">VTHO</span></p> | |
<b-form-group label="To Address:" label-for="toaddress"> | |
<b-form-input id="toaddress" v-model.trim="toaddress"></b-form-input> | |
</b-form-group> |
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
/** | |
* Get token amount of holder from a contract. | |
* @param {String} addressContract 0x started address. | |
* @param {String} addressHolder 0x started address. | |
*/ | |
async function getTokenBalance (addressContract, addressHolder) { | |
const balanceOfABI = { | |
'constant': true, | |
'inputs': [ | |
{ |
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
pragma solidity ^0.5.11; | |
contract Hello { | |
uint public counter; | |
constructor () public { | |
counter = 0; | |
} | |
function increaseAmount () public { |
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
// Using thor-devkit.js | |
const Transaction = require('thor-devkit/dist/transaction').Transaction | |
// Construct transaction body. | |
const txBody = { | |
// Test-net: 0x27, Main-net: 0x4a. | |
chainTag: 0x27, | |
// After which block this tx should happen? | |
// 16 characters of block ID. | |
blockRef: '0x004984e1064ed410', |
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
// Import library | |
const cry = require('thor-devkit/dist/cry') | |
const Transaction = require('thor-devkit/dist/transaction').Transaction | |
// User private key. | |
const originPriv = Buffer.from( | |
'2a0cbfe49ea7c18e89b87be4237e1717823fc16b52dc02e91fb30af122fba9b3', | |
'hex' | |
) | |
// User public address: 0x881Ab2380017870C49a9A114806C05F3CFE406e2 |
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
// HTTP function definition | |
async function getSponosrSignature(sender, txBody) { | |
const url = 'http://localhost:3000/' | |
const response = await fetch(url, { | |
method: 'POST', | |
headers: { | |
'Accept': 'application/json', | |
'Content-Type': 'application/json' | |
}, | |
body: JSON.stringify({ |
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
const express = require('express') | |
const cry = require('thor-devkit/dist/cry') | |
const Transaction = require('thor-devkit/dist/transaction').Transaction | |
const app = express() | |
app.use(express.json()) | |
const port = 3000 | |
app.post('/', function(req, res) { |