Giter Club home page Giter Club logo

create-ico's Introduction

Create ICO

TDCOIN, TDC

  • Send in Ethers, receive tokens
  • use truffle , Open Zeppelin
  • test with ganache , infura , a testnet network and MyCrypto

Methods

  • Admin() : gives the admin address
  • decimals(): gives the decimals of the token
  • _decimals() : read the decimal given to the tokenn
  • allowlistedNumber() : gives the number of address in the list for those allowed to get token
  • balanceOf(address) : gives the balance of token of an address
    • balanceOf(address): with the admin address give the current total supply of token
  • name() : gives the name of the token
  • symbol() : gives the symbol of the token
  • totalSupply() : gives the initial total supply
  • allowlistAddress(address) : add an address to the list if it is not alredy in it (only admin)
  • mint(address,uint256) : mint token to an arbitrary address (only admin)
  • send_from_admin(address,uint256) : send token from the current supply to an arbitrary address (only admin)
  • fallback() gets called when money is sent to this contract , and getToken(amount, rate) is called and token is sent if the sender is in the allowed list (only members)

Installation

  1. Truffle :

Truffle is a development environment where you can easily develop smart contracts with it’s built-in testing framework, smart contract compilation, deployment, interactive console

npm install -g truffle

create a project :

mkdir nameoffile
cd file
truffle init

usefull commands :

Compile: truffle compile
Migrate: truffle migrate
Test contracts: truffle test
Console : truffle console
Version : truffle version
  1. Ganache :

Ganache acts as our local Blockchain to deploy and test the contract functionality locally before deploying it to a public testnet.

  • follow instruction here to download the .appx
  • launch the application and create a Workspace with the name TDToken for example
  • links Truffle to Gnache (follow this) :
  • In the truffle-config.js
module.exports = {
  networks: {
    ganache: {
      host: "127.0.0.1",     // Localhost (default: none)
      port: 7545,            // Standard Ethereum port (default: none)
      network_id: 5777,       // Any network (default: none)
    }
  },
  • Then add in the Ganache Worksplace the truffle-config js file

To test with Ganache : In the 2_deploy_contracts.js : choose your Ganache address as Admin address

var TDCOIN = artifacts.require("TDToken");
module.exports = function (deployer) {
  // deployer.deploy(#Nom, #TotalSupply, #Address Admin)
  //deployer.deploy(TDCOIN,100000000000000, '0x.......................'); // address admin pour Ganache
  deployer.deploy(TDCOIN,100000000000000, '0x......................'); // address (Metamask) admin pour Infura 
};
# Compile 
truffle compile

# Migrate
truffle migrate --reset -- network ganache

# Test
truffle console 
# in the console 
TDToken.deployed().then((instance) => {td = instance;})
#example :
td.name()
td.totalSupply()

When contracts are deployed to the local Blockchain in Ganache if we look at the first row from the accounts table we can see that the ETH balance has dropped slightly and that the number of transactions has increased above 0

  1. Openzeppelin

OpenZeppelin is a library that consists of multiple, reusable contracts, to build ERC20 tokens for example.

npm init
npm install @openzeppelin/contracts

Deploy to testnet with Infura

npm install @truffle/hdwallet-provider

In the truffle-config.js

const HDWalletProvider = require("@truffle/hdwallet-provider");
const mnemonic = """; //#mnemonic"
 networks: {
    ganache: {
      host: "127.0.0.1",     // Localhost (default: none)
      port: 7545,            // Standard Ethereum port (default: none)
      network_id: 5777,       // Any network (default: none)
    },
    infura: {
      provider: function() {
        //return new HDWalletProvider(mnemonic, "https://rinkeby.infura.io/v3/290e39df33ee41b6bdbc079bd550fa7a")
        return new HDWalletProvider(mnemonic, "https://ropsten.infura.io/v3/290e39df33ee41b6bdbc079bd550fa7a")
      },
      network_id: 4
    },
  • create a new project -ENDPOINTS => Rinkeby/Ropsten/..
  • To test with testnet
  • get token in a faucet

In the 2_deploy_contracts.js : choose your metamask address as Admin address Your account need to have enough gas and ether to deploy the contracts

# Migrate
truffle migrate --reset --network infura

Once the contract is migrated , you can get the contract address in the console

  • In Metamask you can add a token with the contract address and the token will be displayed in your metamask
  • In MyCrypto choose to interact with your contract in the given testnet , then find the abi in the build\contracts\TDToken.json and paste it
  • Now you can interact with the contract and test it
  • In Metamask send ether to the contract address with Metamsk to get token

Start

Install the dependencies and devDependencies

npm install

Deploy localy with Ganache or in a testnet with Infura and Test

  • Contract - Send ether to this contract if you want to receive our token (Ropsten testnet) , ask us before to add you in the member list Contract address : 0x03553e45d727aCE1841c12327E1bbBB268BcdD14

More

create-ico's People

Contributors

redek-zelton avatar bjeabby1507 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.