This file contains hidden or 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 Web3 = require('web3'); | |
const fs = require('fs'); | |
const solc = require('solc'); | |
/* | |
* connect to ethereum node | |
*/ | |
const ethereumUri = 'http://localhost:8540'; | |
const address = '0x004ec07d2329997267Ec62b4166639513386F32E'; // user |
This file contains hidden or 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 Web3 = require('web3'); | |
/* | |
* connect to ethereum node | |
*/ | |
const ethereumUri = 'http://localhost:8540'; | |
let web3 = new Web3(); | |
web3.setProvider(new web3.providers.HttpProvider(ethereumUri)); |
This file contains hidden or 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.4.8; | |
/* | |
* Basic token | |
* Basic version of StandardToken, with no allowances | |
*/ | |
contract BasicToken { | |
address public owner; | |
uint public totalSupply; | |
mapping(address => uint) balances; |
This file contains hidden or 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 fs = require('fs'); | |
const solc = require('solc'); | |
---- connect的部分省略 ---- | |
/* | |
* Compile Contract and Fetch ABI, bytecode | |
*/ | |
let source = fs.readFileSync("./contracts/BasicToken.sol", 'utf8'); | |
console.log('compiling contract...'); |
This file contains hidden or 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
/* | |
* connect to ethereum node | |
*/ | |
const ethereumUri = 'http://localhost:8540'; | |
const address = '0x004ec07d2329997267Ec62b4166639513386F32E'; // user | |
let web3 = new Web3(); | |
web3.setProvider(new web3.providers.HttpProvider(ethereumUri)); | |
if(!web3.isConnected()){ |
This file contains hidden or 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
---- 前面省略 ---- | |
/* | |
* deploy contract | |
*/ | |
let gasEstimate = web3.eth.estimateGas({data: '0x' + bytecode}); | |
console.log('gasEstimate = ' + gasEstimate); | |
let MyContract = web3.eth.contract(abi); | |
console.log('deploying contract...'); |
This file contains hidden or 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.4.10; | |
contract SimpleOracle { | |
// 儲存response | |
mapping(uint256 => bytes) responses; | |
// 傳出去的Query Event | |
event QueryEvent(uint256 _id, bytes _query); | |
// 使用者query功能 |
This file contains hidden or 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.4.10; | |
contract SimpleOracle { | |
// 增加owner | |
address owner; | |
// 增加responder | |
address public responder; | |
mapping(uint256 => bytes) responses; | |
// 設定owner |
This file contains hidden or 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.4.10; | |
contract Oracle { | |
address owner; | |
address public cbAddress; // callback address | |
function Oracle() { | |
owner = msg.sender; | |
} |
This file contains hidden or 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.4.10; | |
contract OracleResolver { | |
address owner; | |
address public oracleAddress; | |
function OracleResolver() { | |
owner = msg.sender; | |
} |
OlderNewer