Docs - SliceLedger
  • What is Slice Ledger?
  • SliceLedger Key Features
  • SliceLedger Wallet
    • SliceLedger Crypto Wallet
      • Slice Web Extension
    • SliceLedger Explorer
    • SliceLedger DEX
    • SliceLedger NFT Market
  • Sliceledger Chain Network
    • Sliceledger Chain Mainnet
    • Sliceledger Chain Testnet
    • CLI Commands
    • Audit
    • Slice Faucet
  • Integrating Metamask
    • Add SliceLedger Chain Network to Metamask
    • Config Custom Token
    • How to Reset Metamask Wallet
  • Slice Ledger Protocols
    • SLICE Game
    • SLICE Reward
    • SLICE Privacy
  • SliceLedger Exclusive Products
    • Bharat NFT Marketplace
    • Bharat Token
    • Slice Crypto Wallet
    • Slice Wallet Extension
    • Bouquet NFT Collection
  • Enterprise Blockchain
    • Diamond Industry
  • SLICE Token
    • Technical
    • Utility
    • Coin Distribution
  • Developer Guide
    • Token Standards
      • SLICE-20 Tokens
      • SLICE-721 Tokens
    • Verify Smart Contract
  • Masternode
    • Masternode Requirements
    • Masternode Setup Guide
    • Run a Full SliceLedger Node
    • Apply For SliceLedger Masternode
    • Resign as Masternode
  • API
    • accounts
    • blockNumber
    • call
    • chainId
    • estimateGas
    • gasPrice
    • getBalance
    • getBlockByHash
    • getBlockByNumber
    • getBlockTransactionCountByHash
    • getBlockTransactionCountByNumber
    • getCode
    • getLogs
    • getStorageAt
    • getTransactionByBlockHashAndIndex
    • getTransactionByBlockNumberAndIndex
    • getTransactionByHash
    • getTransactionCount
    • getTransactionReceipt
    • getUncleByBlockHashAndIndex
    • getUncleByBlockNumberAndIndex
    • getUncleCountByBlockHash
    • getUncleCountByBlockNumber
    • getWork
    • hashrate
    • mining
    • protocolVersion
    • sendRawTransaction
    • submitWork
    • syncing
    • net_listening
    • net_peerCount
    • net_version
    • web3_clientVersion
    • parity_nextNonce
    • Filter methods
    • newFilter
    • newBlockFilter
    • getFilterChanges
    • uninstallFilter
  • Deploying on SliceLedger Chain
    • Using Remix
    • Using Truffle
    • Using Hardhat
Powered by GitBook
On this page
  • Hardhat-config
  • Compile Smart contract file
  • Deploying on SliceLedger Network
  1. Deploying on SliceLedger Chain

Using Hardhat

PreviousUsing Truffle

Last updated 2 years ago

There are a few technical requirements before we start. Please install the following:

  • (comes with Node)

Once we have those installed, To install Hardhat, you need to create an npm project by going to an empty folder, running npm init, and following its instructions. Once your project is ready, you should run

$ npm install --save-dev hardhat

To create your Hardhat project run npx hardhat in your project folder Let’s create the sample project and go through these steps to try out the sample task and compile, test and deploy the sample contract.

The sample project will ask you to install hardhat-waffle and hardhat-ethers.You can learn more about it

Hardhat-config

  • Go to hardhat.config.js

  • Update the hardhat-config with SliceLedger-network-credentials

  • Create .env file in the root to store your private key

  • Add SliceLedgerscan API key to .env file to verify the contract on SliceLedgerscan. You can generate an API key by creating an account

require('dotenv').config();
require("@nomiclabs/hardhat-ethers");
require("@nomiclabs/hardhat-etherscan");

module.exports = {
  defaultNetwork: "SliceLedger",
  networks: {
    hardhat: {
    },
    SliceLedger: {
      url: "https://test-slice-rpc.com/",
      accounts: [process.env.PRIVATE_KEY]
    }
  },
  solidity: {
    version: "0.8.3",
    settings: {
      optimizer: {
        enabled: true,
        runs: 200
      }
    }
  },
}

Make sure to update the Solidity compiler version here based on what is required in your contract(s).

Compile Smart contract file

$ npx hardhat compile

Deploying on SliceLedger Network

Run this command in root of the project directory:

$ npx hardhat run scripts/sample-script.js --network SliceLedger

Contract will be deployed on SliceLedger Chain Testnet, it look like this:

Compilation finished successfully
Greeter deployed to: 0xF0B2F5AbE5A52B5BF85B2320A730D1Ed714c1af3

Remember your address would differ, Above is just to provide an idea of structure. Congratulations! You have successfully deployed Smart Contract. Now you can interact with the Smart Contract.

You can check the deployment status here:

Node.js v10+ LTS and npm
Git
in this guide
https://testnet-slicescan.io/