Skip to content

Instantly share code, notes, and snippets.

@mcveat mcveat/all.js
Created Aug 2, 2017

Embed
What would you like to do?
bob = personal.newAccount("bobs password")
john = personal.newAccount("johns password")
miner.setEtherbase(bob)
miner.start(1)
admin.sleepBlocks(2) // halts script execution until 2 blocks are mined
miner.stop()
abi = [{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[],"payable":false,"type":"function"},{"inputs":[{"name":"initialSupply","type":"uint256"}],"payable":false,"type":"constructor"}]
contract = eth.contract(abi)
code = "0x6060604052341561000f57600080fd5b604051602080610310833981016040528080519060200190919050505b806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b505b61028f806100816000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806370a0823114610049578063a9059cbb14610096575b600080fd5b341561005457600080fd5b610080600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506100d8565b6040518082815260200191505060405180910390f35b34156100a157600080fd5b6100d6600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506100f0565b005b60006020528060005260406000206000915090505481565b806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561013b57600080fd5b6000808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020540110156101c657600080fd5b806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550806000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055505b50505600a165627a7a72305820b1e8c908d9cdc4837ab94f73527a626af9fd9ef444d7874c1bd2f43ec35a70a80029"
personal.unlockAccount(bob, "bobs password")
contractInstance = contract.new(1000, {data: code, from: bob, gas: 1000000})
miner.start(1)
admin.sleepBlocks(2)
miner.stop()
receipt = eth.getTransactionReceipt(contractInstance.transactionHash)
KrugerToken = contract.at(receipt.contractAddress)
KrugerToken.transfer.sendTransaction(john, 10, {from: bob})
miner.start(1)
admin.sleepBlocks(2)
miner.stop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.