Skip to content

datsproject/dats_contracts

Repository files navigation

Dats Desktop Contracts

...

Node Kurulumu

    node -v

Eğer bilgisayarınızda Node.js yüklü değilse bu bu adresten size uygun versiyonu yükleyebilirsiniz veya Hardhat'in önerdiği kurulum ve güncelleme yöntemlerini inceleyebilirsiniz.


Hardhat Çalışma Ortamının Kurulumu

Node Projesinin Başlatılması

    npm init --yes

Hardhat'in İndirilmesi

    npm install --save-dev hardhat

Hardhat'in Çalıştırılarak Çalışma Ortamın Yapısının Seçilmesi

    npx hardhat

Gerekli Eklentilerin Kurulumu (Ethers.js, Waffle)

    npm install --save-dev @nomiclabs/hardhat-ethers ethers @nomiclabs/hardhat-waffle ethereum-waffle chai

hardhat.config.js Dosyasının Hazırlanması

    //require("@nomiclabs/hardhat-ethers");
    require("@nomiclabs/hardhat-waffle");

    const PRIVATE_KEY = "PRIVATE_KEY";


    module.exports = {
        solidity: "0.8.2",
        networks: {
          mainnet: {
            url: `https://api.avax.network/ext/bc/C/rpc`,
              accounts: [`${PRIVATE_KEY}`]
          },
          fuji: {
            url: `https://api.avax-test.network/ext/bc/C/rpc`,
              accounts: [`${PRIVATE_KEY}`]
          }
        }
    };

Dosya Dizinleri

    boilerplate/
    ├── hardhat.config.js
    ├── package.json
    ├── package-lock.json
    ├── node_modules
    ├──── contracts/
    ├──── test/
    └──── scripts/

Compile İşlemi

    npx hardhat compile

OpenZeppelin Kontratlarını Kullanmak için

    npm install @openzeppelin/contracts

Testlerin Çalıştırılması

    npx hardhat test

Kontratların Deploy Edilmesi

    npx hardhat run <deploy-scrpit-path>

    npx hardhat run <deploy-scrpit-path> --network <network-name>

    npx hardhat run scripts/deploy.js --network fuji

Yardımcı Fonksiyonlar

Chai Helpers

    await expect(token.transfer(walletTo.address, 1007)).to.be.reverted;

    expect('0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B').to.be.properAddress;
    expect(token).to.not.be.undefined;

    expect(token.balanceOf("0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B")).to.be.equal(0);
    
    expect(token.balanceOf("0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B")).to.be.greaterThan(0);

Ethers Helpers

    await ethers.getContractFactory("Token");
    await ethers.getSigners();
    ethers.utils.parseEther("100");
    ethers.utils.parseUnits("100", 18);
    ethers.utils.formatEther("1000000000000000000");
    ethers.utils.formatUnits("100", 2);
    ethers.constants.MaxUint256;

    const provider = ethers.provider;
    block_number = await provider.getBlockNumber();
    await provider.getBlock(block_number)
    block_timestamp = block.timestamp;

Not: Ethers Playground

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •