⛏️How to use SDK to submit a transaction

We can guide you on adding your smart contract to the Bitkub Chain Developer Console and configure your web application to interact with the smart contract using the Bitkub Chain Developer Console SDK. Here's an explanation of the process:

Configuration at BKC Console

Create Smart Contract

Description: Once the smart contract is deployed, your smart contract needs to connect with Bitkub Chain Developer Center, which typically provides an API or SDK that allows you to interact with the smart contract.

  1. Go to menu: Smart contract.

  2. Click “Add Smart Contract"

  1. Input smart contract name, smart contract address, smart contract type

  • When selecting the smart contract type, it will prefill the required smart contract ABI

  1. Input/Update Smart contract ABI

    • If your smart contract type: is KAP20, we already have two default ABI and can configure them.

    • If your smart contract type: is KAP721, we already have two default ABI and can configure them.

    • If your smart contract type: Is a logic Contract, you can free-style configure them.

  2. Click the “Add.

  3. Congratulations, you successfully added a smart contract.

Create a Smart Contract Version

Description: In versioning, selecting the deployed smart contract to group means organizing deployed smart contracts into groups based on their version number. It is especially in complex smart contract systems where multiple contracts may be interacting with each other.

  1. Go to menu: Smart contract Version.

  2. Click the “Create Smart Contract Version.

  1. Select deployed and added smart contract from the list, then click the “Create” button.

  1. When creating a new smart contract. Its version is automatically created; the previous version will be inactive.

Information:

  • You can only activate one smart contract version per project.

Configuration at your website

Once you have successfully config the smart contract in SDK, you can now use the smart contract function on your website.

const bkn = useContext(BitkubNextSdkContext) as BitkubNextSDK;	
const contracts = bkn.contracts
  • Contract

We will use this object to show how to submit a transaction.

  • As you can see, that function approveBySDK required two arguments

    1. spender

    2. amount

const bkn = useContext(BitkubNextSdkContext) as BitkubNextSDK;	
const contracts = bkn.contracts

const approveContract = bkn.contracts.KAP20[0]
const response = await contract.approve('spender', 'amount');
  • You can use a contract.approve (same method as approveBySDK)

  • Replace the spender and amount with your parameters

🥳 If you have successfully submitted the approve function, you can go back to see the transaction list in SDK Console.

  1. Go to menu: Transaction List

  2. Able to search by transaction address

  3. View transaction id, status, create date, transaction

    • Able to view more detail

    • Able to view transaction log

Last updated