Colony SDK browser demo - connecting to MetaMask
11 |Click the button to connect to MetaMask
12 | 13 |Click the button to connect to MetaMask
12 | 13 |Listen to Colony Events as they unfold...
12 | 13 | 14 | 15 |Let's check the CLNY funding for a Colony
12 | 15 | 16 |1) Let's connect to the Colony first Make sure you have the FUNDING and 12 | ADMINISTRATION permissions in the Root domain of that Colony
13 | 14 | 15 |2) Next we create a team
16 | 17 |3) We need to move some funds to the new team. Make sure the root colony has at least 18 | about 1 unit of the Colony's native token (see message below after connecting)
19 | 20 |4) Then, within that team, send someone some of the Colony's native tokens
21 | 22 | 23 |First make sure that the Colony contracts are deployed locally and the Reputation Oracle is set up. See here for 13 | more 14 | information
15 |We'll be using wallet address 0xb77D57F4959eAfA0339424b83FcFaf9c15407461 to connect to the locally deployed 16 | MetaColony. Any transaction will automatically be signed as we have the private key hardcoded. No connection 17 | to 18 | MetaMask is needed.
19 |Let's check the CLNY funding for the local MetaColony. Make sure to provide the 20 | correct 21 | address given in the `etherrouter-address.json` in the `colonyNetwork` directory.
22 | 23 | 24 | 25 |See colonySDK and colonyStarter for more information.
13 |Check out the source code for the examples here.
15 |These demos interact with LIVE Colonies on Gnosis chain. We recommend to use the Colony 16 | RPC endpoint directly.
17 |These demos interact with a local development RPC endpoint (see here on how to set 36 | it up). MetaMask is not needed, the examples provide a wallet account.
37 |First make sure that the Colony contracts are deployed locally and the Reputation Oracle is set 15 | up.
16 |We'll be using wallet address 0xb77D57F4959eAfA0339424b83FcFaf9c15407461 to connect to the locally deployed 17 | MetaColony. This address was used to deploy the MetaColony locally and is the "owner" of it. Any transaction 18 | will automatically be signed as we have the private key hardcoded. No connection to MetaMask is needed.
19 |1) Let's connect to the ColonyNetwork first Paste in the address from the 20 | `etherrouter-address.json` in the `colonyNetwork` directory
21 | 22 | 23 |2) Then, we mint some CLNY and fund the MetaColony with it (make it at least 24 | 10!)
25 | 26 | 27 |3) Next, we pay someone for a task in the MetaColony's root team (in the MetaColony's native token CLNY - 28 | that's important!)
29 | 30 | 31 |4) Jump forward in time - Reputation is awarded in cycles. In our case it's set to 1 hour. As we have full 32 | control over our local blockchain, Ganache allows us to travel to the future! Fasten your seatbelts, here we
33 |Instructions: 34 |
✅ New reputation hash confirmedto appear in your console (reputation 37 | oracle)
Note: We're using Ganache's evm_increaseTime and evm_mine methods to first increase the block time artificially by one hour and then force a 48 | block to mine. This will trigger the local reputation oracle/miner to award the pending reputation. We have to do 49 | that twice, if the reputation oracle was just started for the first time.
50 |5) Ask the oracle for the user's reputation
51 | 52 |Using wallet address
12 |1) Let's connect to the Colony first For testing, it is beneficial to set the period 13 | length of the motion phases to very low values (e.g. 2 minutes)
14 | 15 | 16 |2) Now we approve some of the CLNY of the above wallet for the Colony and the VotingReputation 17 | staking, 18 | which will remove it from the user's wallet (you only need to do this once for this example)
19 | 20 | 21 |3) Then, we create a motion to pay some of the native token to Carol: 22 | 0x42b9f8673a9187952a5dF24132eEa04268a14BCC (this will also incur reputation if the motion passes) (must be less than the amount that is in the Colony's root team!) 24 |
25 | 26 | 27 |4) Next, we look at the motion more closely
28 | 29 | 30 |You will see the domainId in which the motion was created, the altTarget (which is the OneTxPayment extension in 31 | this case, as we want to execute the `pay` function on it), the encoded action and the stakes remaining for 32 | activation.
33 |5) Okay, now we're ready to stake. Feel free to stake any amount, then get the motion again and see how it 34 | goes up :)
35 | 36 | 37 | 38 |6) We can also simulate voting. For that, we activate both sides by staking the required amount on both 39 | sides from a single address. That usually won't happen in the wild (except if someone wants to force voting for 40 | some 41 | reason). Stake on both sides and then get the motion data to see if remainingYayStakes and 42 | remainingNayStakes are both 0.0 43 |
44 | 45 | 46 |7) Reveal the vote After the voting phase is over the votes can be revealed. Only if a vote is revealed it 47 | is counted and the voting reward is paid out
48 | 49 |8) If the motion was successful, we can finalize it. In our example we can only finalize it if we wait 50 | long 51 | enough after staking was only activated for Yay or if we voted for Yay.
52 | 53 |First make sure that the Colony contracts are deployed locally and the Reputation Oracle is set 14 | up.
15 |We'll be using wallet address 0xb77D57F4959eAfA0339424b83FcFaf9c15407461 to connect to the locally 16 | deployed MetaColony. This address was used to deploy the MetaColony locally and is the "owner" of it. Any 17 | transaction will automatically be signed as we have the private key hardcoded. No connection to MetaMask is 18 | needed. 19 |
20 |1) Let's connect to the ColonyNetwork first Paste in the address from the 21 | `etherrouter-address.json` in the `colonyNetwork` directory
22 |This will also set up the Motions&Disputes extension in the MetaColony with testing settings as well as 23 | distribute 24 | an initial amount of reputation and CLNY to the two addresses we're using for this example: 25 | 0xb77D57F4959eAfA0339424b83FcFaf9c15407461 and 0x9df24e73f40b2a911eb254a8825103723e13209c. 26 |
27 | 28 | 29 |2) Now we install the VotingReputation extension and bootstrap some reputation (you only need to 30 | do 31 | this once for this example)
32 | 33 |3) Now we approve some of the CLNY of 0xb77D57F4959eAfA0339424b83FcFaf9c15407461 for the Colony and 34 | the 35 | VotingReputation staking, which will remove it from the user's wallet (you only need to do this 36 | once for this example) 37 |
38 | 39 |4) Jump forward in time - When we connected to the Colony above, the two addresses mentioned were awarded 40 | some reputation. It is awarded in cycles; in our case it's set to 1 hour. As we have full control over our local 41 | blockchain, Ganache allows us to travel to the future! Fasten your seatbelts, here we go (take 43 | a look at the console for the reputation oracle!)!
44 |Instructions: 45 |
✅ New reputation hash confirmedto appear in your console (reputation 48 | oracle)
Note: We're using Ganache's evm_increaseTime and evm_mine methods to first increase the block time artificially by one hour and then force a 59 | block to mine. This will trigger the local reputation oracle/miner to award the pending reputation. We have to do 60 | that twice, if the reputation oracle was just started for the first time.
61 |5) Then, we create a motion to pay some CLNY to a third address: 62 | 0x27ff0c145e191c22c75cd123c679c3e1f58a4469 (this will also incur reputation if the motion passes) (make it less than 100!) 64 |
65 | 66 | 67 |6) Next, we look at the motion more closely
68 | 69 | 70 |You will see the domainId in which the motion was created, the altTarget (which is the OneTxPayment extension in 71 | this case, as we want to execute the `pay` function on it), the encoded action and the stakes remaining for 72 | activation.
73 |7) Okay, now we're ready to stake. Feel free to stake any amount, then get the motion again and see how it 74 | goes up :)
75 | 76 | 77 | 78 |8) We can also simulate voting. For that, we activate both sides by staking the required amount on both 79 | sides from a single address. That usually won't happen in the wild (except if someone wants to force voting for 80 | some 81 | reason). Stake on both sides and then get the motion data to see if remainingYayStakes and 82 | remainingNayStakes are both 0.0 83 |
84 | 85 | 86 |9) Reveal the vote After the voting phase is over (you will need to wait ~6 87 | minutes 88 | - we are forwarding time again for that), the votes can be revealed. Only if a vote is revealed it is counted and 89 | the voting reward is paid out
90 | 91 |10) If the motion was successful, we can finalize it. In our example we can only finalize it if we wait 92 | long 93 | enough (~6min - the time is forwarded again when you press the button) after staking was only activated for Yay or 94 | if we voted for Yay.
95 | 96 |