0

The goal is to create a contract which allows party B to withdraw from party A's account according to some formula. I don't want to use an escrow model, rather just to:

  1. Let A attest that they are okay with B withdrawing at some future point in time.
  2. Set a threshold for how much/ long B can withdraw.

Are there any examples or best practices for this?

2

You can't withdraw from someone else's account directly. You can, however, create a smart contracts in which A can deposit the money. Then, B is allowed to withdraw the money from the smart contract for a certain period of time. Of B hasn't withdrawn the money and the period has ended, A can withdraw the money from the smart contract

2

I recomend using a Vault. You may check OpenZeppelin RefundVault. Users send some funds to this Vault and depending of your business logic, user can request a refund and withdrawl funds.

https://github.com/OpenZeppelin/openzeppelin-solidity/blob/v1.10.0/contracts/crowdsale/distribution/utils/RefundVault.sol

1

For ERC20 tokens, you can use the approve function to allow someone else to withdraw from your token holdings:

https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md#approve

Allows _spender to withdraw from your account multiple times, up to the _value amount. If this function is called again it overwrites the current allowance with _value.

For Ether, you can set up something like a multi-signature wallet where individuals have access to the same funds stored in that contract. This contract may not work exactly as you intend out of the box, but should be a great start:

https://github.com/ConsenSys/MultiSigWallet

  • Cool, thanks! I suppose I could also use WETH instead of the multisig wallet? – Paul Razvan Berg Jul 29 '18 at 17:56
  • I am not verify familiar with WETH, but I assume you should be able to answer your own question since you are the one looking for a specific functionality. – Shawn Tabrizi Jul 29 '18 at 18:29

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.