---
tags: RIPs
---
# Escrow web3 notes
## abis and code
### Minion
github https://github.com/raid-guild/moloch-minion
contract https://github.com/raid-guild/moloch-minion/blob/develop/contracts/Minion.sol
abi https://github.com/raid-guild/moloch-minion/blob/develop/src/abi/minion.json
mainnet:
```
minion: {
kovan: "0x98B550E95E90ADFA6D9841fAB937D81FcFEab6D2",
mainnet: "0x17405148473E521b62cBCf8eBd929E8A30C4D3aA"
},
dao: {
kovan: "0x501f352e32ec0c981268dc5b5ba1d3661b1acbc6",
mainnet: "0xbeb3e32355a933501c247e2dbde6e6ca2489bf3d"
},
```
### Lexlocker
github https://github.com/lexDAO/LexLocker/blob/lexguildlocker/LexGuildLocker.sol
contract https://etherscan.io/address/0xb0d95049a9d78a1f5f111ce18f25e0294da78418#code
abi https://gist.github.com/dekanbro/6341b5be4c66d83ab239a60fd0044c5e
Ethereum mainnet deployment: 0x6d2A62442dAf0448561d130b40BaC6159264b1c0
LexDAO Arbitration: 0x06153608b799a3da838bf7c95fe21309d2e33b53
(need testnet deployments)
## Submitting minion proposal
submit minion proposal with escrow register function
to submit a minion proposal you will need to hex encode the the transaction to the lexLocker registerLocker function first
lex locker function
```sol
function registerLocker( // register locker for token deposit and client deal confirmation
address client, // client payment address
address[] calldata provider, // array of providers for spoils split (first address has the power to lock) [multisigAddress, daoAddress]
address resolver, // LexDAO Arbitration address
address token, // payment token (DAI)
uint256[] calldata amount, // array of amounts to be paid at each milstone. example if each miles stone payment is 1000 [100, 900]
uint256 cap, // must be total of all milestone amounts example if 2 milestones of [100, 900] cap would be 2000
uint256 milestones, // total number of milestones
uint256 termination, // date in the future where client can take back funds 'safety valve'
bytes32 details // some extra data about the escrow, not sure we'll need this for anything because we will be hydrating metadata with the database
) external {...}
```
web3js helper function
`web3.eth.abi.encodeFunctionCall`
example
```javascript
const registerFunc = lexLockerAbi.find(
func => func.name && func.name === "registerLocker"
);
const hexData = web3.eth.abi.encodeFunctionCall(registerFunc, [
client,
provider,
resolver,
token,
amount,
cap,
milestones,
termination,
details)
]);
// contract is the minion contract
contract.methods
.proposeAction(lexLockerAddr, 0, hexData, descriptionForDaoProposal)
.send({ from: currentUserAddr })
```
## register flow
* submit form data to airtable
* airtable returns unique id
* submit web3 minion proposal
* update airtable record with txHash and/or (if Minion minion index)
* when transaction is complete return url to escrow detail to raid member (if minion the deposit function should not be available until the minion proposal passes and is executed) (if not minion save escrow index)
* (if not minion) submit proposal to dao with details of escrow
* (if minion) this transaction has not been submitted to lexLocker yet only to the minion where it can be voted on by the dao
* (if minion) when proposal passes and is processed minion transaction can be executed. I think this will have to happen manually or through the minion.raidguild.org frontend. Issue here is we will not have the lexlocker index until this is executed so i think we'll have to update the db manually. this seems to be the biggest pain here, also lexLocker registerLocker function does not return the index.
## deposit flow
* (if Minion) after minion proposal has been executed the client can deposit funds
* the client will have to approve the token for at least the amount of the cap
* client must have at least the amount of the cap funds in address
* deposit function is called with the lexLocker index
## lexLocker Events and Deposit struct
can retrieve lexLocker deposit information with.
* released - the released field will show how much is released and can be used to deduce the current milestone.
* confirmed - the confirmed field will show if the deposit has been made yet
`contract.methods.deposits(<index>)`
```
struct Deposit {
address client;
address[] provider;
address resolver;
address token;
uint8 confirmed;
uint8 locked;
uint256[] amount;
uint256 cap;
uint256 released;
uint256 termination;
bytes32 details;
}
```
### events
```
event RegisterLocker(address indexed client, address[] indexed provider, address indexed resolver, address token, uint256[] amount, uint256 cap, uint256 index, uint256 termination, bytes32 details);
event DepositLocker(uint256 indexed index, uint256 indexed cap);
event Release(uint256 indexed index, uint256[] indexed milestone);
event Withdraw(uint256 indexed index, uint256 indexed remainder);
event Lock(address indexed sender, uint256 indexed index, bytes32 indexed details);
event Resolve(address indexed resolver, uint256 indexed clientAward, uint256 indexed providerAward, uint256 index, uint256 resolutionFee, bytes32 details);
```
## notes
I would suggest using web3Modal https://github.com/Web3Modal/web3modal because it supports most providers and wallets, supports mobile deeplinking with walletConnect and has a standard interface most people are used to. And it just works