Using Klaytn Plugin on Remix

Klaytn is an EVM-based blockchain that strives to secure high tooling interoperability with Ethereum. In line with this goal, the Klaytn Plugin is now available on the Remix IDE, through the initiative of Ozys, an official Klaytn Dev Tool partner.

By using the Klaytn Plugin on Remix, you can develop, deploy, and interact with smart contracts on the Klaytn blockchain and execute various Klaytn-specific transactions. In the following sections, we will take a look at how to deploy a smart contract on Klaytn, use Klaytn on-chain Fee Delegation through the Klaytn Remix Plugin’s “fee payer” function, as well as connect to Kaikas.

Deploying Contract 

  1. Activate the Klaytn Remix Plugin

Activate the Klaytn plugin in the PLUGIN MANAGER.

  1. Add Greeter.sol

In the FILE EXPLORERS panel, let’s add a sample greeter contract that prints a simple greeting, like the one below. It’s written in Solidity, so it uses the .sol extension.

pragma solidity 0.5.6;
contract Mortal {
    /* Define variable owner of the type address */
    address payable owner;
    /* This function is executed at initialization and sets the owner of the contract */
    constructor () public { owner = msg.sender; }
    /* Function to recover the funds on the contract */
    function kill() public { if (msg.sender == owner) selfdestruct(owner); }
}

contract KlaytnGreeter is Mortal {
    /* Define variable greeting of the type string */
    string greeting;
    /* This runs once when the contract is created */
    constructor (string memory _greeting) public {
        greeting = _greeting;
    }
    /* Main function */
    function greet() public view returns (string memory) {
        return greeting;
    }
}
  1. Compile your contract

Now go to the SOLIDITY COMPILER panel, set it to the right version, and click `Compile greeter.sol`. 

  1. Deploy the contract

In this example we are using Baobab, Klaytn’s test network. Enter your ACCOUNT and make sure you top it up using test KLAY from the Klaytn  [Faucet](https://baobab.wallet.klaytn.foundation/faucet).

And voila! You will see that the contract is deployed. Now let’s invoke the ‘greet’ function!

In the terminal you will see the greeting was successfully called.

Using Fee Delegation

Now let’s try using Fee Delegation. Fee Delegation is one of Klaytn’s features that allows transaction costs to be paid by another account.

  1. Designate Fee Payer

To delegate fees, insert the address of the account that fees will be delegated to in the FEE PAYER field. Next to that, you can set the percentage of the fee to be paid on behalf of ACCOUNT. Choosing 100 means that the FEE PAYER (that account that the transaction fee will be delegated to) will assume 100% of the transaction fees.

  1. Deploy the contract

Next, click on Deploy and the KlaytnGreeter contract will be created in the terminal. You can click on the link to Klaytnscope to confirm the details of this transaction.

Connecting Kaikas

The Klaytn Remix Plugin also supports Kaikas. 

  1. Select Injected Caver

To connect to Kaikas, select “Injected Caver” in the ENVIRONMENT dropdown as shown below.

A pop-up window will appear to request access to your account, to connect Kaikas to Remix. 

  1. Grant access

G

  1. Deploy the contract

Now let’s deploy the same KlaytnGreeter contract again.

  1. Confirm the transaction

A pop-up window will appear for you to confirm the transaction.

Click confirm and then we can look at the result in the terminal.

In this tutorial, we looked at how to use Klaytn Plugin on Remix.

Moving forward, Klaytn’s official Dev Tool Partner Ozys will be providing updates to the caver-js features as well as adding more Providers.

Stay tuned for more updates!

Connecting MetaMask

You can also use MetaMask to make transactions via Klaytn Plugin. Before you connect MetaMask, make sure to add Klaytn Network following the instructions [here](​​https://docs.klaytn.foundation/dapp/tutorials/connecting-metamask#connect-to-klaytn-network). In this example, it is connected to Baobab.

1. Select Injected Web3

In ENVIRONMENT, select `Injected Web3`.

You will see a pop-up window requesting your confirmation.

Follow the steps and you will see that your account is automatically connected to Kaikas.

2. Deploy Contract

Let’s deploy the contract. Click on the orange button with a nice greeting.

3. Check Gas Fee

Since Klaytn has a fixed gas price, you have to check that the gas fee is at 250. You will see a pop-up notification after you deploy the contract. Click on `Advanced > Edit`.

Confirm that Max base fee and Priority Fee are at 250 GWEI.

4. Confirm the transaction

Come back to the previous notification and confirm the transaction.

You can see the result in the terminal as shown below. 

In this tutorial, we looked at how to use Klaytn Plugin on Remix.

Moving forward, Klaytn’s official Dev Tool Partner Ozys will be providing updates to the caver-js features as well as adding more Providers.

Stay tuned for more updates!

MORE FROM Tutorials

Announcements

Monthly round-up: September 2022

05/10/2022

Ecosystem

Klaytn Partners with ZetaChain to Advance Built-in Omnichain Interoperability

03/10/2022

Announcements

HackBoston Klaytn Challenge Winners

28/09/2022

CATEGORIES

© Klaytn Foundation 2022. All rights reserved.
© Klaytn Foundation 2022. All rights reserved.