LogoLogo
Cryptum.ioGitHub
  • 🌐Cryptum
    • What is Cryptum
    • DeFi Market
    • Ecosystem
      • Bitcoin
      • Ethereum
      • Polygon
      • Avalanche C-Chain
      • BNB Chain
      • Cardano
      • Celo
      • Hathor
      • Solana
      • Stellar
      • XRP Ledger
      • Stratus
      • Hyperledger Besu
  • 👝Products
    • Dashboard Analytics
    • Tokenization
    • Crypto Checkout
      • Overview
      • Getting started
      • Checkout Dashboard
        • Creating your Store
        • Customer Checkout screens
        • Analytics
        • Managing Wallets
        • Creating Collections and NFTs
        • Linking Products to NFTs
        • Monitoring Orders
      • Checkout API
        • Authentication
        • Store
        • Orders
          • Handling Orders
    • Wallets
    • DeFi-as-a-Service
    • On & Off Ramp (soon)
    • E-commerce Plugins
      • Wordpress NFT Plugin
        • How to install NFT Plugin
        • Connect your Credentials to NFT Plugin
      • Wordpress Checkout Plugin
        • How to install Checkout Plugin
        • Connect your Credentials to Checkout Plugin
      • Plugins Guides
        • Creating your Store
        • Manage your Wallets
        • Creating Collections and NFTs
        • Linking Products to NFTs
        • Monitoring Orders
        • Monitoring Store (Analytics)
  • 💻Community Edition
    • Overview
    • Architecture
    • Start for free
    • Getting started
    • Dashboard guide
      • 🔑Creating a Project (API Key)
      • 🛠️Start building!
      • 📊Monitoring your Project
      • 📈Monitoring Requests
    • SDK guides
      • Get test currencies
      • Chainlink
        • 📈Price Feeds
        • ⚙️Automation
        • 🎲VRF
        • 🛤️CCIP
        • 🛤️CCIP
        • Project Examples
          • Lottery
          • Send Message CCIP
      • Wallets
      • Balances
      • Prices
      • Tokens
        • EVM Tokens (ERC-20)
        • Solana Tokens (SPL)
        • Cardano Tokens
        • Stellar Tokens
        • XRP Tokens
        • Hathor Tokens
      • NFTs
        • EVM NFTs (Ethereum, Polygon and others)
        • NFTs on Solana
        • NFTs on Hathor Network
      • Queries
        • Wallet information
        • Get transaction by hash
        • Get block information
        • Get transaction receipt by hash
        • Get fees information
        • Get NFT data
        • Get NFT balance
        • Get UTXOs (Unspent transaction outputs)
      • Uniswap
      • Staking
      • Smart Contracts
        • Deploy custom Smart Contracts
        • Loot Box
    • Features and credits
      • Avalanche C Chain
      • Bitcoin
      • BNB Chain
      • Cardano
      • Celo
      • Ethereum
      • Hathor
      • Polygon
      • Solana
      • Stellar
      • XRP Ledger
      • Stratus
    • API guides
      • API Cryptum
      • API Connector
  • 📃GLOSSARY
    • Blockchain terms
    • Cryptum terms
Powered by GitBook
On this page
  • Call smart contract method
  • Create smart contract call transaction
  • Deploy a smart contract
  1. Community Edition
  2. SDK guides
  3. Smart Contracts

Deploy custom Smart Contracts

EVM Based Protocols (Ethereum-virtual-machine)

PreviousSmart ContractsNextLoot Box

Last updated 1 year ago

const sdk = new CryptumSdk({
  environment: 'testnet',
  apiKey: 'YOUR-API-KEY'
})

Call smart contract method

sdk.contract.callMethod(opts)

Call a method of a smart contract and receive its value without creating a transaction in the blockchain.

  • opts.contractAddress (string) (required) - contract address of the smart contract.

  • opts.contractAbi (array) (required) - json interface of the method (for more info on ).

  • opts.method (string) (required) - smart contract method.

  • opts.params (array) - parameters to be passed to the method.

  • opts.protocol (string) (required) - .

const { result } = await sdk.contract.callMethod({
  contractAddress: '0x2B751008...6a763e72788Db9Ca',
  contractAbi: [
    {
      constant: true,
      inputs: [],
      name: 'message',
      outputs: [
        {
          internalType: 'string',
          name: '',
          type: 'string',
        },
      ],
      payable: false,
      stateMutability: 'view',
      type: 'function',
    },
  ],
  method: 'message',
  params: [],
  protocol: 'CELO'
})
console.log(result)
// Result value from smart contract method

Create smart contract call transaction

sdk.contract.callMethodTransaction(opts)

Call a method of a smart contract that will generate a transaction in the blockchain.

  • opts.wallet (Wallet) (required) - wallet calling the smart contract and signing this transaction.

  • opts.contractAddress (string) (required) - contract address of the smart contract.

  • opts.method (string) (required) - smart contract method.

  • opts.params (array) - parameters to be passed to the method.

const { hash } = await sdk.contract.callMethodTransaction({
  wallet,
  contractAddress: '0x3f2f3D45196...8f530165eCb93e772',
  contractAbi: [
    {
      constant: false,
      inputs: [
        { name: 'param1', type: 'string' },
        { name: 'param2', type: 'uint256' },
        { name: 'param3', type: 'uint256' },
      ],
      name: 'executeMethodName',
      outputs: [{ name: '', type: 'bool' }],
      payable: false,
      stateMutability: 'nonpayable',
      type: 'function',
    },
  ],
  method: 'executeMethodName',
  params: ['param1', 2, 3],
  protocol: 'BSC'
})

Deploy a smart contract

sdk.contract.deploy(opts)

Deploy a smart contract source code written in Solidity to the blockchain.

  • opts.wallet (Wallet) (required) - wallet deploying the smart contract.

  • opts.contractName (string) (required) - main contract name. There could be many contracts in the source code, but you must specify which one is the main one to initialize it after deployment.

  • opts.params (array) (required) - parameters to be passed to the constructor of the main contract.

  • opts.source (string) (required) - source code of the contract encoded in UTF-8.

const { hash } = await sdk.contract.deploy({
  wallet,
  contractName: 'HelloWorld',
  params: ['hello'],
  source: fs.readFileSync(`${__dirname}/contracts/HelloWorld.sol`, { encoding: 'utf8' }),
  protocol: 'POLYGON'
})

opts.contractAbi (array) (required) - json interface of the method (for more info on ).

opts.protocol (string) (required) - .

opts.protocol (string) (required) - .

💻
contract ABI
EVMs only
contract ABI
EVMs only
EVMs only