Skip to content

Instantly share code, notes, and snippets.

@zelig
Created October 9, 2015 12:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zelig/b855b7b1e121a9b43abd to your computer and use it in GitHub Desktop.
Save zelig/b855b7b1e121a9b43abd to your computer and use it in GitHub Desktop.
https://github.com/ethersphere/swarm/wiki/Swap
https://github.com/ethersphere/go-ethereum/pull/20
./geth --datadir ~/tmp/swap/01 account new
# 0xaf420ffb7b146c7198177e5510b04b6966b17358 (passwd = bzz)
then you need to mine some ether on an easy chain
./geth --datadir ~/tmp/swap/01 --nodiscover --networkid 322 --mine --dev console 2>> swap01.log
then stop it, you will have ether
./geth --datadir ~/tmp/swap/01 --bzzaccount 0xaf420ffb7b146c7198177e5510b04b6966b17358 --unlock 0xaf420ffb7b146c7198177e5510b04b6966b17358 --password <(echo bzz) --nodiscover --networkid 322 --port 30301 --vmodule cheque=6,swap=6 console 2>> swap01.log
^
var chequebookContract = web3.eth.contract([{"constant":false,"inputs":[],"name":"kill","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"beneficiary","type":"address"}],"name":"getSent","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"beneficiary","type":"address"},{"name":"amount","type":"uint256"},{"name":"sig_v","type":"uint8"},{"name":"sig_r","type":"bytes32"},{"name":"sig_s","type":"bytes32"}],"name":"cash","outputs":[],"type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"deadbeat","type":"address"}],"name":"Overdraft","type":"event"}]);
var chequebook = chequebookContract.new(
{
from: web3.eth.accounts[0],
data: '606060405260008054600160a060020a03191633179055610201806100246000396000f3606060405260e060020a600035046341c0e1b58114610031578063d75d691d14610059578063fbf788d61461007e575b005b61002f60005433600160a060020a03908116911614156100b857600054600160a060020a0316ff5b600160a060020a03600435166000908152600160205260409020546060908152602090f35b61002f600435602435604435606435608435600160a060020a03851660009081526001602052604081205485116100ba575b505050505050565b565b30600160a060020a039081166c0100000000000000000000000090810260609081529188160260745260888690526048812080825260ff8616608090815260a086905260c0859052909260019260e0926020928290866161da5a03f11561000257505060405151600054600160a060020a0390811691161461013b576100b0565b85600160a060020a031660006001600050600089600160a060020a03168152602001908152602001600020600050548703604051809050600060405180830381858888f19350505050156101b557846001600050600088600160a060020a03168152602001908152602001600020600050819055506100b0565b60005460408051600160a060020a03929092168252517f2250e2993c15843b32621c89447cc589ee7a9f049c026986e545d3c2c0c6f9789181900360200190a185600160a060020a0316ff',
gas: 3000000
}, function(e, contract){
if (typeof contract.address != 'undefined') {
console.log(e, contract);
console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
}
})
vi ~/tmp/swap/01/bzz/af420ffb7b146c7198177e5510b04b6966b17358/config.json
I1009 12:40:22.645600 35106 swap.go:126] [SWAP] peer chequebook: 0x4297653fcdfaa189b0af1c44d612be4f3c3ee15e, beneficiary: 0x39327685447fa487429063f4331000c2b02f082e, balance: 0 has too much debt (balance: 30, target: 30)
I1009 12:40:22.645860 35106 protocol.go:395] [BZZ] listening address: enode://042e1fe4c581e81fc062bb7da3592f37cc1813f6ce335f91c4b46c351ebacd45905ee42d575263ea0e00f2803dd0e021757fe5b1f04845445a776437e22ba0b42f@:::30301
I1009 12:40:22.645899 35106 kademlia.go:246] [KΛÐ]: remove node 088854ec: enode://04187572238f56c1aec9ef586c8ccb09f47a90665d67133a9822aaa6e9b7d066289e089edf27e4f55abdfbfd4f93b4f0f66cc5af0a3be68cd7a8977c666ace4d54@:::30301 (30) from table
I1009 12:58:30.772505 35602 cheque.go:90] new chequebook initialised from 0x4297653fcdfaa189b0af1c44d612be4f3c3ee15e (owner: 0xaf420ffb7b146c7198177e5510b04b6966b17358)
I1009 12:58:30.772533 35602 swap.go:131] [BZZ] SWAP auto deposit ON for 0xaf420f -> 0x429765: interval = 5m0s, threshold = 100, buffer = 200)
I1009 12:58:32.927257 35602 nat.go:111] mapped network port tcp:30301 -> 30301 (ethereum p2p) using UPNP IGDv1-IP1
I1009 13:03:30.778413 35602 xeth.go:991] Tx(0xb319e2df67b849bf688973d934e1aa0c5081448b2519f147807f1fcb1d0d5e65) to: 0x4297653fcdfaa189b0af1c44d612be4f3c3ee15e
I1009 13:03:30.778439 35602 cheque.go:268] deposited 200 wei to chequebook (0x4297653fcdfaa189b0af1c44d612be4f3c3ee15e, balance: 200, target: 200)
I1009 13:03:30.779650 35602 xeth.go:991] Tx(0xde420a5157776a96da66aeb7f4ff569ebcb22aecacdc549dba47f4c8ad7d6abb) to: 0x4297653fcdfaa189b0af1c44d612be4f3c3ee15e
I1009 13:03:30.779708 35602 cheque.go:268] deposited 200 wei to chequebook (0x4297653fcdfaa189b0af1c44d612be4f3c3ee15e, balance: 200, target: 200)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment