poanetwork / posdao-contracts

Smart contracts for POSDAO (Proof of Stake Decentralized Autonomous Organization consensus), a DPOS consensus implemented in Solidity and running within EVM with swappable BFT consensus
Other
106 stars 50 forks source link

Proposal: add an ERC20 contract and a deployment script for it #27

Closed vkomenda closed 5 years ago

vkomenda commented 5 years ago

An ERC20 token contract is required to put stakes on observers. It is currently disabled in make_spec.js. There is an analogous contract in poa-bridge-contracts which could possibly be used as such an ERC20 token contract, even though it implements ERC677, an updated version of ERC20. In particular, we'd use the stake and withdraw functions called from here.

Such a contract can be deployed to a live network (including but not limited to a live test network) following the deployment approach also in poa-bridge-contracts. The deployment script shall call ValidatorSetBase::setErc20TokenContract in order to set the address of the ERC20 token account. This function is dead code at the moment.

varasev commented 5 years ago

I think, it would be better if you used the deployment script from poa-bridge-contracts (it's too complex, though) to get the ERC677BridgeTokenRewardable contract deployed on the test network during the initial staking epoch in your pos-test-setup repo, and then called ValidatorSetBase::setErc20TokenContract() by the owner from your script located in pos-test-setup.

The deployment solution is too complex for this task because it deploys other parts of the bridge which is not needed for pos-test-setup at the moment, so you could write your own simple deployment script which would deploy only the ERC677BridgeTokenRewardable.

I didn't include the ERC677BridgeTokenRewardable into pos-contracts because it is the part of the bridge (again, to not to mix different parts in one repo).

Note that the ERC677BridgeTokenRewardable has mint function which can be used by the owner to mint some tokens for some addresses if needed.

vkomenda commented 5 years ago

I moved this issue to the integration test repo.