Bringing community pools to the REN ecosystem
- Install brownie:
- https://iamdefinitelyahuman.medium.com/getting-started-with-brownie-part-1-9b2181f4cb99
- https://eth-brownie.readthedocs.io/en/stable/install.html
- https://www.youtube.com/watch?v=nkvIFE2QVp0
- Install solhint
npm install -g solhint
Run solhint (solidity linter):
solhint 'contracts/**/*.sol'
- Launch a python virtual env:
>> python -m venv venv # create a new env called venv
>> source venv/bin/activate # activate it
>> deactivate # deactivate it once you are done
- Install deps
>> python -m pip install -r requirements.txt
- Update requirements.txt
In case you add some extra deps, please update requirements.txt
>> python -m pip freeze > requirements.txt
-
Create a new file called
.env
from.env.sample
. Add your Metamask mnemonic and Infura project id. -
Init brownie console. This will create a local blockchain plus 10
accounts
loaded with eth associated to your Metamask.
>> brownie console
- Mint a ERC20 token called REN and deploy RenPool contract to local net. You'll get a fresh instance every time you init the brownie console.
>> renToken, renPool = run('deploy')
- You can now interact with the
renToken
andrenPool
contracts using any of theaccounts
provided by brownie and any of the contracts' methods.
Get some ren tokens from the faucet
>> acc = accounts[1]
>> renToken.balanceOf(acc)
>> 0
>> renToken.callFaucet({'from': acc})
>> renToken.balanceOf(acc)
>> 1000000000000000000000
Deposit ren tokens into the ren pool
>> tx1 = renToken.approve(renPool, 100, {'from': acc})
>> tx2 = renPool.deposit(100, {'from': acc})
Verify that the ren pool balance has increased
>> renPool.totalPooled()
>> 100
Withdraw some tokens
>> renPool.withdraw(5, {'from': acc})
>> renPool.totalPooled()
>> 95
- Running tests (open a new terminal).
>> brownie test
https://www.freecodecamp.org/news/how-to-deploy-a-react-application-to-netlify-363b8a98a985/
Install Netlify CLI: npm install netlify-cli -g
.
>> yarn run setEnv:<TARGET_NETWORK>
>> yarn run deploy
The app is deployed to https://renpool.netlify.app/
- Get a funded wallet
- Set .env file pointing to the desired network
- run brownie console
- accounts.add('PRIVATE_KEY')
- renToken, renPool = run('deploy')
https://www.quicknode.com/guides/vyper/how-to-write-an-ethereum-smart-contract-using-vyper
This mix comes with everything you need to start using React with a Brownie project.
-
Install Brownie, if you haven't already. You must be using version
1.9.0
or newer. -
Download the mix.
brownie bake react-mix
-
Install the React client dependencies.
cd client yarn install
-
In MetaMask or another web3 browser extension, load the following seed phrase:
hill law jazz limb penalty escape public dish stand bracket blue jar
These accounts will automatically be funded.
-
Open the Brownie console. Starting the console launches a fresh Ganache instance in the background.
$ brownie console Brownie v1.9.0 - Python development framework for Ethereum ReactMixProject is the active project. Launching 'ganache-cli'... Brownie environment is ready.
-
Run the deployment script to deploy the project's smart contracts.
>>> run("deploy") Running 'scripts.deploy.main'... Transaction sent: 0xd1000d04fe99a07db864bcd1095ddf5cb279b43be8e159f94dbff9d4e4809c70 Gas price: 0.0 gwei Gas limit: 6721975 SolidityStorage.constructor confirmed - Block: 1 Gas used: 110641 (1.65%) SolidityStorage deployed at: 0xF104A50668c3b1026E8f9B0d9D404faF8E42e642 Transaction sent: 0xee112392522ed24ac6ab8cc8ba09bfe51c5d699d9d1b39294ba87e5d2a56212c Gas price: 0.0 gwei Gas limit: 6721975 VyperStorage.constructor confirmed - Block: 2 Gas used: 134750 (2.00%) VyperStorage deployed at: 0xB8485421abC325D172652123dBd71D58b8117070
-
While Brownie is still running, start the React app in a different terminal.
# make sure to use a different terminal, not the brownie console cd client yarn start
-
Connect Metamask to the local Ganache network. In the upper right corner, click the network dropdown menu. Select
Localhost 8545
, or:New Custom RPC http://localhost:8545
-
Interact with the smart contracts using the web interface or via the Brownie console.
# get the newest vyper storage contract >>> vyper_storage = VyperStorage[-1] # the default sender of the transaction is the contract creator >>> vyper_storage.set(1337)
Any changes to the contracts from the console should show on the website after a refresh, and vice versa.
When you close the Brownie console, the Ganache instance also terminates and the deployment artifacts are deleted.
To retain your deployment artifacts (and their functionality) you can launch Ganache yourself prior to launching Brownie. Brownie automatically attaches to the ganache instance where you can deploy the contracts. After closing Brownie, the chain and deployment artifacts will persist.
export WEB3_INFURA_PROJECT_ID=YourProjectID
brownie console --network mainnet-fork
To run the test suite:
brownie test
To deploy your contracts to the mainnet or one of the test nets, first modify scripts/deploy.py
to use a funded account.
Then:
brownie run deploy --network kovan
Replace kovan
with the name of the network you wish you use. You may also wish to adjust Brownie's network settings.
For contracts deployed on a live network, the deployment information is stored permanently unless you:
- Delete or rename the contract file or
- Manually remove the
client/src/artifacts/
directory
This mix provides a bare-bones implementation of Create React App, configured to work with Brownie.
To get started with React and building a front-end for your dApps:
- Rimble is an open-source library of React components and guides to help you make dApps. Along with components they provide guides and tutorials to help you get started.
- For more in-depth information, read the Create React App documentation
To get started with Brownie:
- Check out the other Brownie mixes that can be used as a starting point for your own contracts. They also provide example code to help you get started.
- "Getting Started with Brownie" is a good tutorial to help you familiarize yourself with Brownie
- For more in-depth information, read the Brownie documentation
Any questions? Join our Gitter channel to chat and share with others in the community.
- https://renproject.io/
- https://github.com/renproject
- https://docs.renproject.io/developers/docs/deployed-contracts
- https://ethereum.org/en/developers/docs/standards/tokens/erc-20/
- Ren contract addresses on mainnet https://renproject.github.io/contracts-ts/#/mainnet
- Ren contract addresses on testnet https://renproject.github.io/contracts-ts/#/testnet
- https://media.consensys.net/an-definitive-list-of-ethereum-developer-tools-2159ce865974
Get Access to Darknode Rewards without having to have 100k Ren or having to run a Darknode
Create a Pool to Deposit Ren into and when it gets to 100k Ren, we will register the pool and run the darknode for you.
Claim and Withdraw Rewards each Epoch. We do not have access to your rewards or your Ren. graph Withdrawing and Deregistering
We have developed a solution that offers users to get access to their Ren before the pool is deregisered. You simply request a withdraw and if anyone wants to take your spot, they transfer Ren to your wallet and you swap your ownership of the pool to them. You are out and have your Ren, however you will be sacrificing the current epoch rewards as a penalty, which goes to the proud new owners.
Once the pool collectively requests to withdraw more than 50K REN, Pool Owners can Deregister the Pool directly. This will initiate the Deregistering process within the Ren Protocol. Upon completion of the deregistration process, Pool Owners will be able to withdraw their credited Ren deposits. RISKS CAUTION Smart Contract Security
Security is our number 1 focus, however RenPool is a project that is currently unaudited and therefore all users must proceed with caution knowing that funds might be lost if hacks are found. We have a test plan that runs through the scenarios and have been very patient developing the contracts, however we are only human. Our intention is to develop a system that works as designed and benefits the ecosystem as a whole. We strive to lower the barrier to entry for users to get access to darknodes while offering opportunities for flexible withdraws and ultimately increase the amount of nodes being run to further secure the Republic Protocol. As we raise funds, we will proceed with the proper audits. Darknode Operational Risks
When RenPools are Registered and the Darknode is being run by the RenPool team, if for any reason the Darknode is not run properly funds are at risk of being slashed. If a slashing is occurred, there are plans in the future of using DAO funds collected by fees to insure the slashing. Until the nodes are decentralized and the DAO is setup, there are risks of being slashed if the nodes are not running effectively. Users can be rest assured, we have been running darknodes successfully for many months now. We plan on finding a solution that further decentralizes the running of the darknode. Users will still be able to request withdraws and if there is >50% in agreement, the darknode can be de-registered and users can withdraw their funds upon completion of the epochs per the Ren Protocol. Fees
Keep in mind that Ethereum Gas Fees can fluctuate quite a bit and can be very costly. In order to keep the RenPool operational fees are required to be collected. You can view the Fee breakdown below. Fees are subject to change and eventually the rates could be controlled by a future DAO. Collected Fees FEES
Understanding the Fees of the system. % of Ren Deposited into Pool
When depositing tokens into a pool there is a X% fee that will be required to deposit tokens. The rate could eventually be controlled by a DAO; initially it will be set at 5%. To reach a 100k Ren deposited for registering the RenPool, 105k Ren will be required to be deposited. % of Rewards per Epoch
Each epoch collects rewards for running the darknode. The rewards will be available to be withdrawn from the Ren Protocol to the RenPools by the Pool Owners minus X%; which could eventually be a parameter controlled by a DAO. Initially the rate will be set at 5%. For example, if $1,000 worth of rewards are collected by the Pool per epoch, $50 would be retained as fees to the RenPool contract.