Giter Site home page Giter Site logo

bulktransactions's Introduction

Gitcoin Grants Checkout Contracts

This repository contains smart contracts used during the Gitcoin grants checkout process.

Contracts

Bulk Checkout

BulkCheckout.sol improves the checkout UX and reduces gas costs by enabling users to donate to multiple grants with one L1 transaction (ignoring the required ERC20 approval transactions). This contract has been deployed on the following networks,

It was compiled with Solidity 0.6.7.

Batch ZkSync Deposit

The deposit functions on the zkSync contract only allow users to deposit one currency per transaction. This means if a user wants to use zkSync to donate, for example, ETH, USDC, and DAI to different grants, three transactions would be required to deposit all three currencies into zkSync. BatchZkSyncDeposit.sol improves the UX of this process and reduces gas costs by batching these deposit calls, so all three deposits are executed with just one L1 transaction (ignoring the required ERC20 approval transactions).

This contract has been deployed on both Mainnet and Rinkeby at 0x9D37F793E5eD4EbD66d62D505684CD9f756504F6 and was compiled with Solidity 0.6.12.

Development

Setup

  1. Create a file called .env with the following contents:
    INFURA_ID=yourInfuraId
    MNEMONIC_TESTNET="your mnemonic for development" # only needed for deployment
    MNEMONIC_MAINNET="your mnemonic for production" # only needed for deployment
  2. Install dependencies with yarn
  3. Run tests with yarn test

Deployment

To deploy a new version of the above contracts:

  1. Open networks.js and configure the object for the network you want to deploy to
    1. You may want to change the gas price (specified in wei) if deploying to mainnet
    2. You may want to change the derivation path based on the result of the next step. See the @truffle/hdwallet-provider for more information.
  2. Run npx oz accounts and select the network you wish to deploy to. The default account will be used unless otherwise specified in a later step.
    1. If you do not see the desired account, you likely need to change the derivation path. See the @truffle/hdwallet-provider docs linked above for instructions on how to change this
  3. Run the appropriate compile script based on the contract you want to deploy. Either yarn run compile-bulkCheckout or yarn run compile-batchZkSync
  4. Run yarn run deploy and follow the prompts to deploy the contract.
    1. If step 2 did not show the desired account as the default account, but you see the desired account in that list, instead run npx oz deploy --skip-compile --from <desiredAddress>. See the OpenZeppelin CLI docs for more information
  5. Once deployment is complete, you'll see a file in the .openzeppelin folder called <network>.json, where <network> is the network you deployed to. The file contains an array of objects containing information on each contract deployment.

bulktransactions's People

Contributors

apbendi avatar chibie avatar mds1 avatar thelostone-mc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bulktransactions's Issues

Not able to Checkout. Error: Cannot read property 'enable' of undefined

While checking out of the cart with selected grants. It showing error Cannot read property 'enable' of undefined. Using formatic for checkout.

Describe the bug

The bug is not allowing to confirm the checkout and is showing error

To Reproduce

First go and select a Grant, Add to Cart, Checkout, Click Fund items and the error will show.

Expected behavior

Display Error: Cannot read property 'enable' of undefined

Screenshots

Error

Incorrect filename in test

In the add-zksync-contract branch, https://github.com/gitcoinco/BulkTransactions/blob/add-zksync-contract/test/batch-zkSync-deposit-test.js#L6 has an incorrect contract name. it should be BatchZkSyncDeposit (just change the first letter to a capital B). I'm guessing you're developing on Windows where that would translate to the same file? Linux and Mac are case-sensitive with filenames however and running the test gives the following error:

Error: /home/mike/work/truffle/BulkTransactions/build/contracts/batchZkSyncDeposit.json: ENOENT: no such file or directory, open '/home/mike/work/truffle/BulkTransactions/build/contracts/batchZkSyncDeposit.json'
    at Object.openSync (fs.js:443:3)
    at Object.readFileSync (fs.js:343:35)
    at Object.readFileSync (/home/mike/work/truffle/BulkTransactions/node_modules/jsonfile/index.js:61:22)
    at loadArtifact (/home/mike/work/truffle/BulkTransactions/node_modules/@openzeppelin/test-environment/node_modules/@openzeppelin/contract-loader/lib/index.js:47:23)
    at TruffleLoader.BaseLoader.fromArtifact (/home/mike/work/truffle/BulkTransactions/node_modules/@openzeppelin/test-environment/node_modules/@openzeppelin/contract-loader/lib/index.js:65:18)
    at Object.<anonymous> (/home/mike/work/truffle/BulkTransactions/test/batch-zkSync-deposit-test.js:6:37)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.exports.requireOrImport (/home/mike/work/truffle/BulkTransactions/node_modules/mocha/lib/esm-utils.js:20:12)
    at Object.exports.loadFilesAsync (/home/mike/work/truffle/BulkTransactions/node_modules/mocha/lib/esm-utils.js:33:34)
    at Mocha.loadFilesAsync (/home/mike/work/truffle/BulkTransactions/node_modules/mocha/lib/mocha.js:427:19)
    at singleRun (/home/mike/work/truffle/BulkTransactions/node_modules/mocha/lib/cli/run-helpers.js:156:15)
    at exports.runMocha (/home/mike/work/truffle/BulkTransactions/node_modules/mocha/lib/cli/run-helpers.js:225:10)
    at Object.exports.handler (/home/mike/work/truffle/BulkTransactions/node_modules/mocha/lib/cli/run.js:366:11)
    at innerArgv.then.argv (/home/mike/work/truffle/BulkTransactions/node_modules/yargs/lib/command.js:241:49)
    at process._tickCallback (internal/process/next_tick.js:68:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
error Command failed with exit code 1

Bulk Donation Contract Spec

@mds1 Requesting feedback before we dive in. I think this will be pretty simple and most of the real "logic" will live in the frontend.

Contract Specs

The contract has one method. It takes:

  • Array of ERC20 addresses
  • Array of token amounts
  • Array of addresses for donations

Each array should be the same length. Each parameter in each array should map positionally., i.e. (erc20s[0], amounts[0], donationAddrs[0]) should represent a donation of (token, amount, receiver).

Using SafeMath & SafeERC20, the contract should loop over the elements in the array and perform transferFrom operations. It any fail, the full tx should revert. The contract should assume approve calls are done prior.

All of this should be pretty extensively tested. We should also run some tests to determine expected gas per donation, so as to put a sane limit on the cart's front end to avoid risking out of gas exceptions if users load up their cart.

What am I missing? Any questions or improvements?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.