Using external web services to interact with KAI token swap contract

KardiaChain
KardiaChain
Published in
6 min readJan 7, 2021

DISCLAIMER: We strongly warn you not to send KAI token or any cryptocurrencies directly to KAI token address or KAITokenSwap contract address instead of interacting with these contracts’ functions. Those funds will be lost and we won’t take responsibility for your actions.

KAITokenSwap contract: https://etherscan.io/address/0xef945ffF5AEd7E0646bA196E50ad19a978C164eF

Official KAI smart contract: https://etherscan.io/address/0xD9Ec3ff1f8be459Bb9369b4E79e9Ebcf7141C093

Connect your wallet with MyEtherWallet or Etherscan

You can easily connect your TrustWallet, MyEtherWallet, AtomicWallet, etc. to https://www.myetherwallet.com/ or https://etherscan.io/ to interact with KAITokenSwap contract using WalletConnect QR code.

Using MyEtherWallet

Firstly, click “Access My Wallet” to connect your current wallet/device, which is holding KAI token ERC20, to MyEtherWallet (MEW) website.

After clicking “MEW wallet”, you can choose whether connect with your MEW wallet app or any mobile wallet which support WalletConnect or WalletLink protocol.

Just open your MEW wallet app or others wallet app to scan the QR code in the WalletConnect section. The scan QR code button in some mobile wallet apps is shown below.

After scanning and approving the confirmation prompt in your app, your wallet info and balance should be shown up on MyEtherWallet web UI.

Make sure you are on an Ethereum mainnet in the “ETH” section, not any Ethereum testnet like “ROP” (Ropsten) or “RIN” (Rinkeby).

Using Etherscan.io

Make sure you are in Ethereum mainnet explorer at domain https://etherscan.io/, not in a testnet explorer like https://ropsten.etherscan.io/ or https://rinkeby.etherscan.io/. MetaMask and other mobile wallets connecting via WalletConnect protocol will connect to the current Etherscan network.

In case you are using Etherscan.io to interact with smart contracts, you need to navigate to the “Write Contract” section of KAI token smart contract at https://etherscan.io/address/0xD9Ec3ff1f8be459Bb9369b4E79e9Ebcf7141C093#writeContract and scan the QR code to connect with your mobile wallet using WalletConnect protocol.

After scanning the QR code using mobile wallet apps, Etherscan will show the successfully connected address. You can start interacting with contracts’ functions from now.

Approve the KAITokenSwap contract to transfer your ERC20 KAI

DISCLAIMER: You must allow the KAITokenSwap contract to transfer an amount of KAI ERC20 token (from your address) to itself. We cannot track your swapped amount transparently if you simply send that amount of KAI to the token swap contract yourself.

Using MyEtherWallet

Specify KAITokenSwap contract address and ABI

Go to https://www.myetherwallet.com/interface/interact-with-contract. We need the KAI token contract address and its ABI to interact with its “approve” function.

Put these values into the corresponding fields in the “Interact with contract” screen then click “Continue”.

Approving

After that, you need to approve the KAITokenSwap contract to deposit an amount of KAI ERC20 token (from your address) to itself. The input amount of KAI token you want to contribute must be multiplied by 1018 due to its decimal. You can use https://eth-converter.com/ to easily perform this conversion. Put the KAI amount to the “Ether” field and use the converted output at the “Wei” field as input data to interact with contract functions.

You can choose the contract function to interact with in the dropdown box next to contract address input. In this case, you will select the “Approve” function with the description below.

Function: approve(spender address, value uint256)

Parameters:

  • Spender (address): is KAITokenSwap contract address. This means KAITokenSwap contract has rights to transfer an amount of KAI token from your wallet because of your allowance. The value of this field is KAITokenSwap contract address 0xef945ffF5AEd7E0646bA196E50ad19a978C164eF.
  • Value (uint256): is the converted KAI amount (in Wei) you want to contribute.

After filling necessary parameters, click the “Write” button and confirm in your mobile device to send the approve transaction.

Using Etherscan.io

Etherscan.io has saved KAITokenSwap contract address and ABI after our source code verification. You just need to approve, without specifying the contract address and ABI like MyEtherWallet above.

Go to https://etherscan.io/address/0xD9Ec3ff1f8be459Bb9369b4E79e9Ebcf7141C093#writeContract and deposit an ERC20 KAI token amount to swap, using function “approve”. Remember that the amount must be converted to Wei first, like in MyEtherWallet section above, and spender address is KAITokenSwap contract address 0xef945ffF5AEd7E0646bA196E50ad19a978C164eF.

After filling necessary parameters, click the “Write” button and confirm in your mobile device to send the approve transaction.

Deposit ERC20 KAI to swap to mainnet

ATTENTION: This phase 2 swapping allows you to swap any amount of KAI ERC20 token to KAI native mainnet token, not a minimum amount 25001 KAI like phase 1. You can choose which address to store the KAI native token after swapping by declaring the “_toAddress” field while making a deposit to the KAITokenSwap contract. Details of this deposit process are described below.

Using MyEtherWallet

Specify KAITokenSwap contract address and ABI

Go to https://www.myetherwallet.com/interface/interact-with-contract. We need the KAITokenSwap contract address and its ABI to interact with its “depositKAI” function.

Put these values into the corresponding fields in the “Interact with contract” screen then click “Continue”.

Depositing

You can choose the contract function to interact with in the dropdown box next to contract address input. In this case, you will select the “depositKAI” function with the description below.

Function: depositKAI(_toAddress address, _amount uint256)

Parameters:

  • _toAddress (address): is your KAI mainnet native wallet address. You can generate one or access your wallet using your private key/mnemonic phrase at https://wallet.kardiachain.io/ . The amount of KAI token you deposited will be swapped to mainnet and stored in this “_toAddress” after the swapping process.
  • _amount (uint256): is the converted KAI amount (converted in Wei) you want to deposit to swap to KAI mainnet native token. The amount to swap must be equivalent or less than to the amount of ERC20 KAI token you’ve approved before.

After filling necessary parameters, click the “Write” button and confirm in your mobile device to send the approve transaction.

Using Etherscan.io

Go to https://etherscan.io/address/0xef945fff5aed7e0646ba196e50ad19a978c164ef#writeContract and deposit an ERC20 KAI token amount to swap, using its “depositKAI” function. After filling the necessary field, click “Write” and confirm in your mobile device to send the transaction.

Happy swapping!

Website | Official Telegram community | Official Vietnamese community |
Official Announcement | Reddit | Medium | Twitter | Linkedin | Kakaotalk

--

--

KardiaChain
KardiaChain

UNIFIED BLOCKCHAIN ECOSYSTEM — The first fully decentralised interoperable and self-optimised blockchain ecosystem