Skip to content

Instantly share code, notes, and snippets.

View TOMOAKI12345's full-sized avatar

Tomoaki Sato TOMOAKI12345

View GitHub Profile
@TOMOAKI12345
TOMOAKI12345 / gist:eecdf882ac59baa2e62e
Created August 14, 2015 06:38
geth 1.x mining start and stop for private chain
function miness(){
miner.start()
setTimeout(mineStop, 15000);
function mineStop(){
miner.stop()
}
}
@TOMOAKI12345
TOMOAKI12345 / gist:8ad669e479c1d6d36b1b
Last active August 29, 2015 14:26
Token contract
// define token compiled code
var tokenCompiled = '606060405260405160208061025a8339016040526060805190602001505b8080602757506127105b600060005060003373ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600050819055505b506101ef8061006b6000396000f30060606040526000357c01000000000000000000000000000000000000000000000000000000009004806390b98a1114610044578063bbd39ac01461007157610042565b005b61005b6004803590602001803590602001506100b3565b6040518082815260200191505060405180910390f35b610082600480359060200150610098565b6040518082815260200191505060405180910390f35b60006000506020528060005260406000206000915090505481565b600081600060005060003373ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000505410156100f557600090506101e9565b81600060005060003373ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282825054039250508190555081600060005060008573ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828282505401925050819055507f16cdf1707799c6655baac6e2
var csCompiled = '606060405260405160a08061089f8339016040526060805190602001805190602001805190602001805190602001805190602001505b84600060006101000a81548173ffffffffffffffffffffffffffffffffffffffff0219169083021790555083600160005081905550603c830242016003600050819055508160046000508190555080600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908302179055505b50505050506107dc806100c36000396000f3006060604052361561008a576000357c01000000000000000000000000000000000000000000000000000000009004806301cb3b20146102bf57806329dcb0cf146102cc57806338af3eed146102ed5780636e66f6e9146103245780637a3a0e841461035b5780637b3e5e7b1461037c578063a035b1fe1461039d578063dc0d3dff146103be5761008a565b6102bd5b60003490506040604051908101604052803381526020018281526020015060066000506006600050805480919060010190908154818355818115116101365760020281600202836000526020600020918201910161013591906100ec565b808211156101315760006000820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556001820160005060009055506001016100ec565b5090
var tokenABI = [{"constant":false,"inputs":[{"name":"receiver","type":"address"},{"name":"amount","type":"uint256"}],"name":"sendCoin","outputs":[{"name":"sufficient","type":"bool"}],"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"coinBalanceOf","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"inputs":[{"name":"supply","type":"uint256"}],"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"},{"indexed":false,"name":"receiver","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"CoinTransfer","type":"event"}]
var tokenContract =eth.contract(tokenABI);
// this is the token address created
var token = tokenContract.at('0x33e98638ea7f2c2fd83731528fb53802af395d13')
// token balance
> token.coinBalanceOf.call('0x4b0c6f0297cee4b551b6fab3277067b64b238990')
'7'
@TOMOAKI12345
TOMOAKI12345 / gist:def0a7af57dc9fab1336
Last active August 29, 2015 14:26
https://www.ethereum.org/greeter tutorial greeter contract created. By execusing the following code on ethereum console, you will see 'Hello world from 0804 Smart Contract Japan meeting!'
// Greeter contract on main net
> var address = '0x7717efe25b65c8c0fcb97a170b086c17b025a1e1'
> var abi = [{ constant: false, inputs: [ ], name: 'kill', outputs: [ ], type: 'function' }, { constant: true, inputs: [ ], name: 'greet', outputs: [{ name: '', type: 'string' } ], type: 'function' }, { inputs: [{ name: '_greeting', type: 'string' } ], type: 'constructor' } ]
// call the greeter contract
> var greeterFactory = eth.contract(abi)
// contract address
> var greeterInstance = greeterFactory.at('0x7717efe25b65c8c0fcb97a170b086c17b025a1e1')
> greeterInstance
{
address: '0x7717efe25b65c8c0fcb97a170b086c17b025a1e1',
@TOMOAKI12345
TOMOAKI12345 / gist:c16e5d25fdeab6a081b9
Last active August 29, 2015 14:26
token instance error
// After running
] Protocol Versions: [61 60], Network Id: 101
I0801 18:25:42.221005 22260 backend.go:333] Blockchain DB Version: 3
I0801 18:25:42.225142 22260 chain_manager.go:251] Last block (#2971) 11514de287ab8a3b01c2005213172b3150a00c2cbbc5de169700ad631f2a5d40 TD=759914948
I0801 18:25:42.265087 22260 cmd.go:121] Starting Geth/v0.9.36/darwin/go1.4.2
I0801 18:25:42.265172 22260 server.go:311] Starting Server
I0801 18:25:44.390958 22260 nat.go:111] mapped network port udp:30303 -> 30303 (ethereum discovery) using UPNP IGDv1-IP1
I0801 18:25:44.460799 22260 udp.go:205] Listening, enode://a9405e4dbfe2f4f63b4dd825a68e409bc227f0a4d58d77072a5c82a063e26bb21c310d3d7831db536a4d14498a0f8f71a8ff8ad9549efc6e37b1c510182cf1d3@49.135.68.148:30303
I0801 18:25:44.461140 22260 backend.go:554] Server started
I0801 18:25:44.461754 22260 server.go:548] Listening on [::]:30303
@TOMOAKI12345
TOMOAKI12345 / gist:1ba1b58e0877a6fdd261
Created August 1, 2015 09:16
token instance error
> token.coinBalanceOf.call(eth.accounts[0])
to not valid, is required
at InvalidResponse (<anonymous>:-59174:-42)
at send (<anonymous>:-117082:-42)
at call (<anonymous>:-105818:-42)
at call (<anonymous>:-89654:-42)
at <anonymous>:1:1
> token.coinBalanceOf.call()
Verifying I am +tomoakisato on my passcard. https://onename.com/tomoakisato
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Text;
using System.Net;
using System.Threading;
using System.IO;
using System.Diagnostics;
using MonoMac.AppKit;
@TOMOAKI12345
TOMOAKI12345 / gist:8cfb2250ae06967b72ac
Last active August 29, 2015 14:24
token contract deploy but can not deploy the contract on private blockchain.
$ geth --vmdebug --networkid="102" --port 30302 --rpc --rpcaddr="localhost" --unlock=primary --rpcport="8080" --datadir="/tmp/eth/62/01" --rpccorsdomain="http://localhost:8089" console
I0706 00:53:23.865413 90895 backend.go:301] Protocol Version: 60, Network Id: 102
I0706 00:53:23.865458 90895 backend.go:311] Blockchain DB Version: 3
I0706 00:53:23.869976 90895 chain_manager.go:260] Last block (#4637) e0b42b8683e486b02b798a1cfe0423d95a50eab11864608ae94f04d620ec728f TD=2131022819
I0706 00:53:23.904082 90895 cmd.go:148] Starting Geth/v0.9.34-a2ce7b99/darwin/go1.4.2
I0706 00:53:23.904200 90895 server.go:294] Starting Server
I0706 00:53:25.954782 90895 udp.go:189] Listening, enode://566acd0cc55b776414c0e2cc04c5a30e496e1497d722d65df312b3fec06d272b4fa6eda5f317a5698c2c506b78fc7b740e5957b92c911a7e2945bf2f4b6e9398@[::]:30302
I0706 00:53:25.954914 90895 backend.go:526] Server started
I0706 00:53:25.954914 90895 server.go:531] Listening on [::]:30302
Unlocking account 0x0c8109ebfe939768a9ff4eeb2b2fe04487