Giter Club home page Giter Club logo

kickstarterweb3's Introduction

KickStarter Solidity Contract

Allows users to create a unique campaign and generate funds in ether, every individual who contributes to your campaign becomes an approver. In order to use funds the campaign manager needs to create fund usage request which needs to be approved by the contributors/approvers.

About Contract

I have a base contract called Campaign and Campaign Factory. First when i started with contracts i wrote my own contract factory which deploys instances of my existing Campaign Contract which costs lots gas which is was not the right way to do it.

OLD Campaign Factory

//SPDX-License-Identifier: MIT

pragma solidity ^0.8.11;

contract CampaignFactory {

address[] public deployedCampaigns;

function createCampaign(uint _minimum) public {
Campaign newCampaigns = new Campaign(_minimum, msg.sender);
deployedCampaigns.push(address(newCampaigns));
}

function getDeployedCampaigns() public view returns(address[] memory ){
return deployedCampaigns;
}

}

Improvement

To solve this gas issue for factory campaign i came across openzeppelin clones https://blog.openzeppelin.com/workshop-recap-cheap-contract-deployment-through-clones/

The Clones library in OpenZeppelin Contracts includes functions to deploy a proxy using either create (traditional deployment) or create2 (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the deterministic method. The Clones library has been available since OpenZeppelin Contracts 3.4.

Usage/Examples

npm install

Compile Code And Deploy

in order for campaign factory to work you must compile and deploy the Campaign contract which will act as template contract for openzeppelines clone to create clone instances of your campaign contract.

/ethereum/contract/Campaign.sol

##compile the contract [all the contracts and stored in build]
node compile

node deployCampaign.js

##next deploy the contract factory [before this make sure you add previously deployed 
Campaign Factory address in deployCampaignFactory.js file]

node deployCampaignFactory.js

Demo

I have improved this contract by implementing the openzeppline clone contracts.

Learnt Kickstarter Contract From
https://www.udemy.com/course/ethereum-and-solidity-the-complete-developers-guide

kickstarterweb3's People

Contributors

hussainzz avatar

Watchers

 avatar

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.