글로벌 이더리움 커뮤니티 활동

ETHERS.JS를 사용하여 토큰 보내기

GOBT 2021. 5. 24. 09:55

아래 내용은 GOB 개발자의 개발자가 이더리움의 ETHERS.JS를 사용하여 토큰을 보내는 방법을 개발자 언어로 표시한 것이다.

SEND TOKEN USING ETHERS.JS(5.0)

In This Tutorial You'll Learn How To

  • Import ethers.js
  • Transfer token
  • Set gas price according to the network traffic situation

To-Get-Started

To get started, we must first import the ethers.js library into our javascript Include ethers.js(5.0)

Installing

ES6 in the Browser

ES3(UMD) in the Browser

Parameters

  1. contract_address: Token contract address (contract address is needed when the token you want to transfer is not ether)
  2. send_token_amount: The amount you want to send to the receiver
  3. to_address: The receiver's address
  4. send_account: The sender's address
  5. private_key: Private key of the sender to sign the transaction and actually transfer the tokens

NOTICE

signTransaction(tx) is removed because sendTransaction() does it internally.

SENDING PROCEDURES

1. Connect to network (testnet)

Set Provider (Infura)

Connect to Ropsten testnet

2. Create wallet

3. Connect Wallet to net

4. Get current gas price

5. Define Transaction

These variables defined below are dependent on send_token()

Transaction parameters

  1. send_account: address of the token sender
  2. to_address: address of the token receiver
  3. send_token_amount: the amount of tokens to send
  4. gas_limit: gas limit
  5. gas_price: gas price

See below for how to

6. Transfer

HOW TO USE IT

Success!

SEND_TOKEN()

 

Home | ethereum.org

Ethereum is a global, decentralized platform for money and new kinds of applications. On Ethereum, you can write code that controls money, and build applications accessible anywhere in the world.

ethereum.org