# Quick Reference for `swarm-tools-rs` - Github - https://github.com/rndlabs/swarm-tools-rs - Blog - https://mirror.xyz/mfw78.eth/6izrHbhaANY-WuBQsCJbYMyevjQQqdnfJ3sjBhI0rL0 --- ## Topology ### Calculate the daily average reported storage radius ``` swarm-tools --gnosis-rpc <GNOSIS_RPC> topology actual-avg-storage-radius ``` Output: ``` Average storage radius: 8 (from 102 samples) ``` ### Given a radius, output the base overlay address for all neighbourhoods ``` swarm-tools topology dump-base-overlays -r <RADIUS> ``` Output: ``` Base overlay addresses for radius 8: 0000000000000000000000000000000000000000000000000000000000000000 0100000000000000000000000000000000000000000000000000000000000000 0200000000000000000000000000000000000000000000000000000000000000 0300000000000000000000000000000000000000000000000000000000000000 0400000000000000000000000000000000000000000000000000000000000000 ... fb00000000000000000000000000000000000000000000000000000000000000 fc00000000000000000000000000000000000000000000000000000000000000 fd00000000000000000000000000000000000000000000000000000000000000 fe00000000000000000000000000000000000000000000000000000000000000 ff00000000000000000000000000000000000000000000000000000000000000 ``` ### Given a radius, output the number of neighbourhoods ``` swarm-tools topology num-neighbourhoods -r <RADIUS> ``` Output: ``` Number of neighbourhoods for radius 8: 256 ``` ## Overlay ### Calculate an overlay address from it's components ``` swarm-tools overlay calculate -a <NODE_ADDRESS> ``` Output: ``` Overlay address: 0xb79c6bc28d2ad4b29449f106c8f9347bb6c87a1751dec2f97216bd6cef74b073 ``` ### Determine which neighbourhood an overlay is in ``` swarm-tools overlay neighbourhood -r <RADIUS> <OVERLAY> ``` Output: ``` Neighbourhood for overlay b79c6bc28d2ad4b29449f106c8f9347bb6c87a1751dec2f97216bd6cef74b073 with radius 8 is 183 ``` ### Given a radius, output the base overlay address for all neighbourhoods ``` swarm-tools --gnosis-rpc <GNOSIS_RPC> overlay auto-mine -n <NUM_ADDRESSES> ``` Output: ``` Mining 2 addresses... Mining address into neighbourhood 383 for radius 9 Mining overlay address for neighbourhood 383/511 /tmp/.tmpUNCXAA/ecc9b2fd-90f4-4e9c-b991-7610058b05ce -> /home/rp/swarm-tools-rs/bees/bf83cd5fa5f369ca5106379ec0a56c1306ad0fc0e2502c9e7aee2aa2c2a352a3.json Overlay address: bf83cd5fa5f369ca5106379ec0a56c1306ad0fc0e2502c9e7aee2aa2c2a352a3 Base address: bf80000000000000000000000000000000000000000000000000000000000000 Bitmask: ff80000000000000000000000000000000000000000000000000000000000000 Match found after 267 iterations... Mining address into neighbourhood 318 for radius 10 Mining overlay address for neighbourhood 318/1023 Loaded wallet: bf83cd5fa5f369ca5106379ec0a56c1306ad0fc0e2502c9e7aee2aa2c2a352a3 /tmp/.tmpd5eIIJ/cca44d24-7929-4038-8a4d-3f5a432147d1 -> /home/rp/swarm-tools-rs/bees/4f8569272a8f380c2676594dfdf3028412e3818a0002579888c3f1924797d8de.json Overlay address: 4f8569272a8f380c2676594dfdf3028412e3818a0002579888c3f1924797d8de Base address: 4f80000000000000000000000000000000000000000000000000000000000000 Bitmask: ffc0000000000000000000000000000000000000000000000000000000000000 Match found after 554 iterations... Neighbourhood stats: Neighbourhood 0/255: 5 players, total stake: 500000000000000000, avg stake: 100000000000000000 Neighbourhood 1/255: 9 players, total stake: 1100000000000000000, avg stake: 122222222222222222 Neighbourhood 2/255: 11 players, total stake: 1100000000000000000, avg stake: 100000000000000000 Neighbourhood 3/255: 8 players, total stake: 800000000000000000, avg stake: 100000000000000000 Neighbourhood 4/255: 10 players, total stake: 1000000000000000000, avg stake: 100000000000000000 ... Neighbourhood 250/255: 8 players, total stake: 800000000000000000, avg stake: 100000000000000000 Neighbourhood 251/255: 12 players, total stake: 1200000000000000000, avg stake: 100000000000000000 Neighbourhood 252/255: 7 players, total stake: 700000000000000000, avg stake: 100000000000000000 Neighbourhood 253/255: 4 players, total stake: 400000000000000000, avg stake: 100000000000000000 Neighbourhood 254/255: 4 players, total stake: 400000000000000000, avg stake: 100000000000000000 Neighbourhood 255/255: 6 players, total stake: 600000000000000000, avg stake: 100000000000000000 overlay,stake,neighbourhood 000999ed71d02b1751ac5e767019b49ed539da2c069eb6b0cd8d582a9a6a1197,100000000000000000,0 007236683d69dd5ea8d694a54fbe36ccf474d200a3960ee353ac3ac67003e37e,100000000000000000,0 0076b8766778cd18a2ec7aa2749e050d12eb7fb2eeb5ebea0a4f7d7d1ed02e15,100000000000000000,0 00b8ea7db13756d9684f6ad8f35e1eaca10cc9c1885e1a31b3d39fb2892fc57a,100000000000000000,0 ... ff5f56bbcacbf823fbd1fb804b62cd315df5091adfb73350c25b38f9a9b60e17,100000000000000000,255 ff9614ab1cc3d8cce24bcd569d7b2a8337900c854b79523fcdb2f8e44eeeb7b7,100000000000000000,255 ffbbc3f309d3bfbe39a9c5ad65e2e3b0095b6f2c487424698059ffbf1b465c79,100000000000000000,255 ffd6dcb9b3ba8e23eba3c1d70d638d2926d9e2f568a28cd7c6f665e97dfa4b61,100000000000000000,255 ffdc456e32c6fc0184b893db6df09eacc69d5d36c31b833f9efd47c11083aa1d,100000000000000000,255 Total players: 1997 Total stake: 222033333000071328010 Average stake: 111183441662529458 Average neighbourhood population: 7 Lowest neighbourhoods: (4, [64, 215, 253, 146, 129, 202, 139, 147, 18, 57, 175, 93, 104, 36, 254, 125, 97, 185, 133, 157]) Optimum neighbourhood: (11, 1181) Total new stake: 200000000000000000 BZZ ``` ### Mine an overlay address into a specific neighbourhood ``` swarm-tools overlay manual-mine -r <RADIUS> -n <NEIGHBOURHOOD> ``` Output: ``` Mining overlay address for neighbourhood 11/255 Loaded wallet: bf83cd5fa5f369ca5106379ec0a56c1306ad0fc0e2502c9e7aee2aa2c2a352a3 Loaded wallet: 4f8569272a8f380c2676594dfdf3028412e3818a0002579888c3f1924797d8de ... ``` ## Game ### Analyse neighbourhood distribution for the schelling game ``` swarm-tools --gnosis-rpc <GNOSIS_RPC> game -r <RADIUS> ``` Output: ``` Neighbourhood stats: Neighbourhood 0/255: 5 players, total stake: 500000000000000000, avg stake: 100000000000000000 Neighbourhood 1/255: 9 players, total stake: 1100000000000000000, avg stake: 122222222222222222 Neighbourhood 2/255: 11 players, total stake: 1100000000000000000, avg stake: 100000000000000000 Neighbourhood 3/255: 8 players, total stake: 800000000000000000, avg stake: 100000000000000000 ... Neighbourhood 251/255: 12 players, total stake: 1200000000000000000, avg stake: 100000000000000000 Neighbourhood 252/255: 7 players, total stake: 700000000000000000, avg stake: 100000000000000000 Neighbourhood 253/255: 4 players, total stake: 400000000000000000, avg stake: 100000000000000000 Neighbourhood 254/255: 4 players, total stake: 400000000000000000, avg stake: 100000000000000000 Neighbourhood 255/255: 6 players, total stake: 600000000000000000, avg stake: 100000000000000000 overlay,stake,neighbourhood 000999ed71d02b1751ac5e767019b49ed539da2c069eb6b0cd8d582a9a6a1197,100000000000000000,0 007236683d69dd5ea8d694a54fbe36ccf474d200a3960ee353ac3ac67003e37e,100000000000000000,0 0076b8766778cd18a2ec7aa2749e050d12eb7fb2eeb5ebea0a4f7d7d1ed02e15,100000000000000000,0 00b8ea7db13756d9684f6ad8f35e1eaca10cc9c1885e1a31b3d39fb2892fc57a,100000000000000000,0 00bac24893c33fab3d04e31b071aecfaefab40c8cf3bd801d6f3e4d9803825ab,100000000000000000,0 011b870fbab8969ba0ced797b258719594b5f93e026489de59ee00f856bad2ef,100000000000000000,1 01307ae23479a2527d77b76d72961ac7661c35a6781912c56067342746cd5892,100000000000000000,1 ... ff5cb93de1baaea7abd415f82a6388de17bca96c68e906c37bc3b17f2000b68a,100000000000000000,255 ff5f56bbcacbf823fbd1fb804b62cd315df5091adfb73350c25b38f9a9b60e17,100000000000000000,255 ff9614ab1cc3d8cce24bcd569d7b2a8337900c854b79523fcdb2f8e44eeeb7b7,100000000000000000,255 ffbbc3f309d3bfbe39a9c5ad65e2e3b0095b6f2c487424698059ffbf1b465c79,100000000000000000,255 ffd6dcb9b3ba8e23eba3c1d70d638d2926d9e2f568a28cd7c6f665e97dfa4b61,100000000000000000,255 ffdc456e32c6fc0184b893db6df09eacc69d5d36c31b833f9efd47c11083aa1d,100000000000000000,255 Total players: 1995 Total stake: 221833333000071328010 Average stake: 111194653132867833 Average neighbourhood population: 7 Lowest neighbourhoods: (4, [175, 215, 139, 129, 36, 97, 147, 93, 18, 133, 104, 202, 57, 125, 146, 253, 79, 191, 185, 157, 254, 64]) Optimum neighbourhood: (11, 1260) ``` ## Stamps ### Analyse postage stamps ``` swarm-tools --gnosis-rpc <GNOSIS_RPC> stamps ``` Output: ``` Found 5777 events. This may take a while... Processed 500 PostageStamp events Processed 1000 PostageStamp events Processed 1500 PostageStamp events Processed 2000 PostageStamp events Processed 2500 PostageStamp events Processed 3000 PostageStamp events Processed 3500 PostageStamp events Processed 4000 PostageStamp events Processed 4500 PostageStamp events Processed 5000 PostageStamp events Processed 5500 PostageStamp events id,chunks,bytes,created,ttl,expiry d81b25d6f35d4d28d4aec7a546fc8e27f96887617246381f9bac6c511601774d,262144,1073741824,1679442540,30180970,1711063284 95344f3f1e305738a8a5387fc50c2d85e94bf66356a599d6f18e9402a9e050d9,262144,1073741824,1678238845,29049945,1709932259 66086409017b6482a0c7e97aaa11fc9933d6f7790fb5ff91fb0f80ab4c466619,131072,536870912,1678970340,29746755,1710629069 818ea97589ffe7de92540205d47fa4d47ec08edeeec57f0c9a6da6c50359b253,131072,536870912,1679252105,30004385,1710886699 c3b5b2cdc6aaf00a1d73cfae0f81b0bfe4503fdd3723bff3281925711fc60779,131072,536870912,1678056705,28875075,1709757389 ... 2f33758421f2d35a751e1a052c8ccacedab7b06f600f91f0298f84f7aef44fbd,262144,1073741824,1678391110,29196110,1710078424 15cf83bfb5dcb5cc485a84b4334a5b269c3ab8e5b7f21333988d484fd3016b72,131072,536870912,1678460740,29262900,1710145214 34982f9e4a51fa497b66a0740807fd02d8d79a9d4c43516f1c4057bbb395f927,131072,536870912,1679067820,29835305,1710717619 f5555fc404ecfd7d8f2da458ef364338b97530f329a82b6f2057dbb27afb6d1b,262144,1073741824,1678551755,29349305,1710231619 Total chunks: 17335451648 Total size: 66129 GB Round reward: 6.3239727611904000 BZZ ``` ## Wallet ### Use DAI from Ethereum Mainnet to fund the node wallets with BZZ and xDAI on Gnosis Chain ``` swarm-tools --gnosis-rpc <GNOSIS_RPC> wallet fund-from-mainnet ``` Output: ``` Loaded wallet: bf83cd5fa5f369ca5104a79ec0a56c1306ad0fc0e2502c9e7aee2aa2c2a352a3 Loaded wallet: 4f8569272a8f380c2672694dfdf3028412e3818a0002579888c3f1924797d8de Creating funding wallet... ./bees/0bb38c9c-5d5f-441c-95f0-b5fb6495f73c -> ./bees/wallet.json Funding wallet created: 0x93a97d357a644283da33f7f71564373b98f44212 Password: 9vTbHffmSXYbSeYRQakTM4pkybFHhRnU Please visit https://gnosisfaucet.com/ and request some xDAI for the funding wallet. Then press enter to continue... ``` ### Use funds in Safe / Funding wallet on Gnosis Chain to fund the node wallets with xBZZ and xDAI ``` swarm-tools --gnosis-rpc <GNOSIS_RPC> wallet fund-from-gnosis-chain ``` Output: ``` Creating funding wallet... ./bees/16999173-744b-4b77-8ddc-947afbc74f03 -> ./bees/wallet.json Funding wallet created: 0xc1a33d9465acbcd8970cb87ebf535b7f02da0330 Password: b8csVC4pRbnaXrc3pTGcNpjXf4xgSsgk Please visit https://gnosisfaucet.com/ and request some xDAI for the funding wallet. Then press enter to continue... ... ``` ### Set xBZZ token approvals on all node wallets for spending by Safe / StakeRegistry on Gnosis Chain ``` swarm-tools --gnosis-rpc <GNOSIS_RPC> wallet approve-all ``` ### Transfer all the xBZZ from the nodes' wallets into Safe on Gnosis Chain ``` swarm-tools --gnosis-rpc <GNOSIS_RPC> wallet transfer-all ``` ### Stake all the nodes on Gnosis Chain ``` swarm-tools --gnosis-rpc <GNOSIS_RPC> wallet stake-all ``` ## Additional Resources - Swarm Network Status - https://crtahlin.shinyapps.io/Swarm-network-stats/ - Mining an overlay and using it for Bee - https://gist.github.com/rampall/6728ce6efbb74eb0f8fc172965ce6c3a