0

I would like to store tokens somewhere else than my wallet due to security reasons. I made a voting system contract and when more than 50% of authorized voters vote for yes, contract transfers limited amount of tokens from safe address to the admin wallet. So if the code is not bugged it's almost impossible to steal tokens, because it would need to hack 2 wallets (where voters' wallets are not associated with each other) at the same time.

function sendTokens(address pAddress, uint pAmount)
    external onlyVotingContract
{
    require(isAdmin(pAddress));
    transferWorker(address(this), pAddress, pAmount);
}

My question is, can this successfuly work if I store tokens at 0x0 instead of address(this)? I must synchronize two contracts to set the same address of total tokens balance in the constructor, so the 0x0 would be the easiest way.

2 Answers 2

1

I don't think this can work without compromising your token contract since there is no known way to sign a transfer from address(0x0). This will lead to messy exceptions to make it possible.

On the other hand, if the voting contract is to be the arbiter of when the tokens should be released, then why not make it the custodian as well? This would be my default approach to such a thing. It means the token contract would not be modified, and the logic governing the admin's ability to withdraw would be clearly defined in the voting contract.

TL;DR

Transfer the restricted tokens to the Voting contract address and make a function to conditionally transfer from Voting to admin.

Hope it helps.

0

Similar to Rob suggestion you can use another contract as a vault to store tokens until some conditions are met.

Having a vault contract allows some flexibility to add extra conditions to release tokens like a multisig approval or a time has elapsed.

On the contrary you will have more code to audit, but it should be easier to audit than having all the code in the same contract.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.