2

I have a smart contract for pallet exchange. There I have a function for exchange pallets between two partners. The point is, I want that you can only run the function when both partners confirm the transaction.

Is there a possibility to write a function with multisig functionality?

  • Yes, it is. The contract would simply hold the asset until both partners have confirmed. – shane Oct 5 '18 at 17:57
1

Is there a possibility to write a function with multisig functionality?

Yes. There are different options, you can take a look this one https://github.com/christianlundkvist/simple-multisig/blob/master/contracts/SimpleMultiSig.sol

0

You can also "outsource" the multisig wallet.

Any Ethereum address (msg.sender) can act as a multisig wallet.

  1. Use any multisig wallet like Gnosis wallet where you have 2-out-2 set up

  2. Create a function modified that checks if the pallet exchange approval function comes from this wallet e.g. by using Whitelist contract mix-in.

0

User Aquila directs you to a good resource, but if you only have two partners, you can have an even simpler implementation. Check out the code below, hope it gives you an overview of how to implement that functionality in its most basic way.

pragma solidity^0.4.25;

contract SimpleMultisig {

  address one;
  address two;

  mapping(address => bool) signed;

  constructor() public {
    one = 0x14723a09acff6d2a60dcdf7aa4aff308fddc160c;
    two = 0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db;
  }

  function Sign() public {
    require (msg.sender == one || msg.sender == two);
    require (signed[msg.sender] == false);
    signed[msg.sender] = true;
  }

  function Action() public returns (string) {
    require (signed[one] == true && signed[two] == true);
    return "Your action here";
    signed[one] = false;
    signed[two] = false;
  }
}

(Ignore the indentation)

Also, you don't need to pre-set the addresses in the constructor, you can have another function do that, and allow them to be changed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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