No funded issue found.
Check out the Issue Explorer
Be the OSS Funding you wish to see in the world.
Looking to fund some work? You can submit a new Funded Issue here .
Time left
Opened
Issue Type
Workers Auto Approve
Project Type
Time Commitment
Experience Level
Permissions
Accepted
Reserved For
MultiMerkleMine Contract
livepeer
Solidity, livepeer, JavaScript, SmartContract
Currently, the MerkleMine smart contract allows the caller to generate a single proof for a single recipient in the `generate()` transaction. This issue is about creating a new convenience smart contract called the `MultiMerkleMine` which allows a caller to submit many proofs for many accounts in a single transaction. This allows a MerkleMiner to more efficiently generate token on unclaimed accounts while saving on gas.
## Description
The MultiMerkleMine contract is purely a convenience wrapper around an existing MerkleMine contract deployed on the blockchain.
* It contains no state of its own, and purely provides convenience methods for invoking the `generate()` function on an existing MerkleMine contract.
* It receives as input an existing MerkleMine contract, an array of recipient addresses, and an array of MerkleProofs.
* It generates token by calling the `generate()` function on the MerkleMine contract once for each unclaimed input recipient address/proof pair.
* It transfers generated token to the caller.
## MultiMerkleMine Spec
### Constructor
`function MultiMerkleMine() public`
takes no arguments, as the contract stores no state
### Public functions
```
function multiGenerate(address _merkleMineContract, address[] _recipients, bytes[] _merkleProofs) external
/**
* 1. Perform validations:
* - length of _recipients == length of _merkleProofs
*
* 2. The input _merkleMineContract address is the MerkleMine contract that this function will be interacting with. Record the MerkleMine token balance for this contract at the start of this function. During this function's execution, this contract's token balance will increase as it generates token, so we'll want to observe how much we generated later, so it can be transferred to the caller.
*
* 3. For each input _recipient and _merkleProof pair (by given index i):
* . - check if MerkleMine contract generated[_recipients[i] == false. If so, call MerkleMine.generate(_recipients[i], _merkleProofs[i])
*
* 4. At the completion of all the calls to generate, check the new balance of the MerkleMine token for this contract. This new balance minus the original balance is equal to the total newly generated token that the caller deserves. Transfer this balance to msg.sender.
*
*/
```
## Tests
Please write tests to cover the following cases:
* Transaction should throw if _recipients length is not equal to the _merkleProofs length.
* msg.sender's new token balance is correct after passing in a full set of valid recipients and proofs.
* msg.sender's new token balance is correct after passing in a set of recipients and proofs that contain some recipients where generated[recipient] returns true. (Essentially this function should be resilient to generate token for the valid recipients where possible without failing the entire transaction).
* If there is an existing token balance for this contract, the msg.sender can only receive what they generated, and not steal any existing token from the contract.
* transaction throws if called before the MerkleMine.callerAllocationStartBlock (should happen transparently via the MerkleMine contract).
## Additional implementation details
* Please use SafeMath library when performing arithmetic operations.
* Look at the existing tests for use of the `MerkleTree` library to easily generate the data for test accounts and accompanying root + proofs.
* Note that this txn will only work after the `MerkleMine.callerAllocationStartBlock`. It is debateable whether this validation should be included or not, since the MerkleMine contract will just throw anyway early on if this time period has not begun. But keep in mind during testing that the current block needs to exceed the callerAllocationStartBlock for the submited proofs to actually validate.
Setup your profile
Tell us a little about you:
Skills
No results found for [[search]] .
Type to search skills..
Bio Required
[[totalcharacter]] / 240
Are you currently looking for work?
[[ option.string ]]
Next
Setup your profile
Our tools are based on the principles of earn (π°), learn (π), and meet (π¬).
Select the ones you are interested in. You can change it later in your settings.
I'm also an organization manager looking for a great community.
Back
Next
Save
Enable your organization profile
Gitcoin products can help grow community around your brand. Create your tribe, events, and incentivize your community with bounties. Announce new and upcoming events using townsquare. Find top-quality hackers and fund them to work with you on a grant.
These are the organizations you own. If you don't see your organization here please be sure that information is public on your GitHub profile. Gitcoin will sync this information for you.
Select the products you are interested in:
Out of the box you will receive Tribes Lite for your organization. Please provide us with a contact email:
Email
Back
Save