Practical Guide to Developing DApps Using IDEs

·

Introduction

Conflux Studio is an integrated development environment (IDE) designed to streamline Conflux smart contract development. This tutorial will guide you through building a simple token application called Coin on the Oceanus network using Conflux Studio.

You’ll learn:

Prerequisites

1. Install the IDE

Download Conflux Studio from its GitHub releases page. Supported platforms:

After installation, follow the setup wizard to install:

2. Create a Wallet

Generate three key pairs:

  1. minter_key: For contract deployment and common operations.
  2. receiver_key: For receiving token transfers.
  3. sponsor_key: For sponsoring transaction fees.

👉 How to export private keys securely

3. Connect to Conflux Network

Switch to the Oceanus testnet via:

Network → Oceanus  

4. Get Test CFX

Request 100 CFX per address via:

Balances after faucet use:

| Key Pair | Balance |
|---------------|---------|
| minter_key | 100 CFX |
| receiver_key| 0 CFX |
| sponsor_key | 100 CFX |

Smart Contract Development

1. Create a Project

  1. Click Project → New.
  2. Name: Coin.
  3. Template: coin.

2. Contract Code (Coin.sol)

Key features:

pragma solidity >=0.5.0 <0.7.0;  
import "./SponsorWhitelistControl.sol";  

contract Coin {  
    address public minter;  
    mapping (address => uint) private balances;  
    event Sent(address from, address to, uint amount);  

    constructor() public { minter = msg.sender; }  

    function mint(address receiver, uint amount) public {  
        require(msg.sender == minter);  
        balances[receiver] += amount;  
    }  

    function send(address receiver, uint amount) public {  
        require(amount <= balances[msg.sender], "Insufficient balance.");  
        balances[msg.sender] -= amount;  
        balances[receiver] += amount;  
        emit Sent(msg.sender, receiver, amount);  
    }  

    function balanceOf(address tokenOwner) public view returns(uint balance) {  
        return balances[tokenOwner];  
    }  

    function add_privilege(address account) public payable {  
        address[] memory a = new address[](1);  
        a[0] = account;  
        SPONSOR.add_privilege(a);  
    }  
}  

3. Compile and Deploy

  1. Build: Click the Build button.
  2. Deploy: Select minter_key as the deployer.
  3. Contract Address: Save as contract_addr.

Interacting with the Contract

1. Mint Tokens

2. Check Balances

3. Transfer Tokens

Sponsored Transactions

1. Set Up Sponsorship

  1. Contract: 0x0888000000000000000000000000000000000001 (system contract).
  2. Methods:

    • set_sponsor_for_collateral: Sponsors storage fees.
    • set_sponsor_for_gas: Sponsors gas fees.

| Parameter | Value |
|--------------------|---------------------|
| contract_addr | Coin contract address |
| Value | 40 CFX |
| Signer | sponsor_key |

2. Whitelist an Address

👉 Test sponsored transactions

Frontend Integration

1. Prerequisites

2. Configure Environment

Update .env:

REACT_APP_CONFLUX_COIN_ADDRESS=contract_addr  

3. Run the Project

yarn start  

FAQs

Q1: How do I reset my wallet in Conflux Studio?
A1: Navigate to Key Manager → Delete Key Pair.

Q2: What if my transaction fails?
A2: Check:

Q3: Can I sponsor transactions for any contract?
A3: Yes, via the system contract’s add_privilege method.

Conclusion

This tutorial covered:

For advanced tasks, explore Conflux Bounty.