0
votes

How can I write a smart contract to give role based permission for a transaction to take place. Say there are five people A, B, C, D and E. A wants to send some ethers to B. But the transaction will not take place until and unless C, D and E give confirmation/approve.

Is it possible to do with ethereum smart contracts? Can someone give me sample code for the same?

Thanks in advance.

1

1 Answers

1
votes

you can create such smart contract although using a multisig account would be better for this case.

you could write a simple contract which validate a transaction after receiving the different needed signatures. e..g :

contract C{
address A;
address B;
address C;


mapping (address=>bool) permission;
function send_permission(address _to, uint value)
{
if(permission[A]&&permission[A]&&permission[A])
_to.transfer(value);
}


function set_permission(bool state)
{
    permission[msg.sender]=state;
}
}