Viblo
  • Posts
  • Questions
  • Discussions
Announcements
No announcement yet.
All Announcements

Trần Hồng Quân

@kim.congqueo

Report
  • Posts
  • Series
  • Questions
  • Answers
  • Clips
  • Followings
  • Followers
  • Tags
  • Reputations
  • Communication

Làm sao để lấy balanceOf , transfer và transferFrom và các thuộc tính của token ERC20 đã có sẵn

Trần Hồng Quân
Answered Nov 3rd, 2020 9:00 AM

Không biết bác đã có câu trả lời chưa. Theo em thì chỉ cần tạo thêm 1 interface

pragma solidity 0.4.25;

contract IERC20 {
    function transfer(address to, uint256 value) public returns (bool);

    function approve(address spender, uint256 value) public returns (bool);

    function transferFrom(address from, address to, uint256 value) public returns (bool);

    function balanceOf(address who) public view returns (uint256);

    function allowance(address owner, address spender) public view returns (uint256);

    event Transfer(address indexed from, address indexed to, uint256 value);

    event Approval(address indexed owner, address indexed spender, uint256 value);
}

Rồi sau đó dùng chỗ nào thì gọi thôi

     IERC20 public tokenAbcxyz= IERC20(0xEFbFc735105cca5B9a6449C499214F74dB321AA9);

Lưu ý địa chỉ đưa vào phải có dạng chữ hoa + chữ thường, nếu không nó sẽ warning invalid checksum.

0

Vượt quá Gas trong Solidity

Trần Hồng Quân
Answered Nov 3rd, 2020 8:55 AM

Nếu bác có dùng truffle thì nhảy vào file truffle-config mà sửa gas.

0

Total post views

856

Reputations

83

Following tags

2

Following users

2

Followers

5

Posts

3

Clips

1

Total questions

0

Total answers

2

Organization


Have no organizations yet.

Posts tendency


Resources

  • Posts
  • Organizations
  • Questions
  • Tags
  • Videos
  • Authors
  • Discussions
  • Recommend System
  • Tools
  • Machine Learning
  • System Status

Services

  • Viblo CV Viblo Code
  • Viblo CV Viblo CV
  • Viblo CTF Viblo CTF
  • Viblo Learning Viblo Learning

Mobile App

Get it on Google Play Download on the App Store
QR code

Links

  • Atom Icon

© 2021 Viblo. All rights reserved.

  • About Us
  • Feedback
  • Help
  • FAQs
  • RSS
  • Terms
  • DMCA.com Protection Status