Skip to content

Instantly share code, notes, and snippets.

View TOMOAKI12345's full-sized avatar

Tomoaki Sato TOMOAKI12345

View GitHub Profile
@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',
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'
var csCompiled = '606060405260405160a08061089f8339016040526060805190602001805190602001805190602001805190602001805190602001505b84600060006101000a81548173ffffffffffffffffffffffffffffffffffffffff0219169083021790555083600160005081905550603c830242016003600050819055508160046000508190555080600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908302179055505b50505050506107dc806100c36000396000f3006060604052361561008a576000357c01000000000000000000000000000000000000000000000000000000009004806301cb3b20146102bf57806329dcb0cf146102cc57806338af3eed146102ed5780636e66f6e9146103245780637a3a0e841461035b5780637b3e5e7b1461037c578063a035b1fe1461039d578063dc0d3dff146103be5761008a565b6102bd5b60003490506040604051908101604052803381526020018281526020015060066000506006600050805480919060010190908154818355818115116101365760020281600202836000526020600020918201910161013591906100ec565b808211156101315760006000820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556001820160005060009055506001016100ec565b5090
@TOMOAKI12345
TOMOAKI12345 / gist:8ad669e479c1d6d36b1b
Last active August 29, 2015 14:26
Token contract
// define token compiled code
var tokenCompiled = '606060405260405160208061025a8339016040526060805190602001505b8080602757506127105b600060005060003373ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600050819055505b506101ef8061006b6000396000f30060606040526000357c01000000000000000000000000000000000000000000000000000000009004806390b98a1114610044578063bbd39ac01461007157610042565b005b61005b6004803590602001803590602001506100b3565b6040518082815260200191505060405180910390f35b610082600480359060200150610098565b6040518082815260200191505060405180910390f35b60006000506020528060005260406000206000915090505481565b600081600060005060003373ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000505410156100f557600090506101e9565b81600060005060003373ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282825054039250508190555081600060005060008573ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828282505401925050819055507f16cdf1707799c6655baac6e2
@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:73e9f140e8449add16ff
Last active December 8, 2015 23:52
private chain geth1.x
// after geth1.x installed.
mkdir /tmp/eth/70
geth console
personal.newAccount('password')
eth.accounts[0]
// you can check the eth.accounts[0] address, copy it and memo to somewhere
// control + c then escape from geth console.
// next make the private net genesisblock json file.
vim privatenet_genesis_block.json
This file has been truncated, but you can view the full file.
{
"nonce": "0x0000000000000042",
"difficulty": "0x400000000",
"alloc": {
"3282791d6fd713f1e94f4bfd565eaa78b3a0599d": {
"balance": "1337000000000000000000"
},
"17961d633bcf20a7b029a7d94b7df4da2ec5427f": {
"balance": "229427000000000000000"
},
@TOMOAKI12345
TOMOAKI12345 / readme.md
Last active August 29, 2015 14:27
npm private module install from github private repo
vim ~/.netrx
machine github.com
  login TOMOAKI12345
  password {oauth_token}

// npm private module installation with writing at package.json 
npm install git+https://github.com/TOMOAKI12345/{private_repo} --save
@TOMOAKI12345
TOMOAKI12345 / gist:9ae5c7068b3a84c5bd5d
Last active August 29, 2015 14:27
check fingerprint on mac
// OSX enviroment
ssh-keygen -lf ~/.ssh/{private_key}
> ~/.ssh/config
Host github.com
User git
Hostname github.com
IdentityFile /Users/{username}/.ssh/{private}
@TOMOAKI12345
TOMOAKI12345 / gist:d9275f5f2e067e125192
Last active August 29, 2015 14:27
fdtrack continue to do starting loop
$ build/bin/geth console
I0821 07:36:52.692526 52529 database.go:74] Alloted 16MB cache to /Users/tomoaki/Library/Ethereum/blockchain
I0821 07:36:52.697946 52529 database.go:74] Alloted 16MB cache to /Users/tomoaki/Library/Ethereum/state
I0821 07:36:52.704361 52529 database.go:74] Alloted 16MB cache to /Users/tomoaki/Library/Ethereum/extra
I0821 07:36:52.707193 52529 backend.go:291] Protocol Versions: [61 60], Network Id: 1
I0821 07:36:52.708534 52529 backend.go:328] Blockchain DB Version: 3
I0821 07:36:52.711741 52529 chain_manager.go:241] Last block (#80898) 2dc873f45d85d0cf14552e0f976071b34f817b3fc0ad80f8bc0061adbd673733 TD=107893388065006012
I0821 07:36:52.804145 52529 cmd.go:124] Starting Geth/v1.0.2-a0303ff4/darwin/go1.4.2
I0821 07:36:52.804450 52529 server.go:312] Starting Server
I0821 07:36:54.837336 52529 udp.go:207] Listening, enode://76aa6d0570fc7b698b57d2b25d43256d849501bbc72cdd817f89181140cde6081dd482106610f9ef6a4513b57092fcea7a5cf9d2c2cfbf14b3e18edf8addbbbe@49.135.72.235:3030