Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

132
Views
la función de transferencia de token de reclamación erc20 no funciona

Tengo este contrato y trato de llamar a la función ClaimFreeToken. El contrato ya no tiene suficientes tokens, pero la función no devuelve un error y tampoco recibe el token. ¿Dónde lo pasé por alto?

 // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; contract TestToken is ERC20 { constructor(uint256 initialSupply) ERC20("Test Token", "TET") { _mint(msg.sender, initialSupply * (10**decimals())); } function claimFreeToken() public payable { transfer(msg.sender, 1000 * (10**decimals())); } }
about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Su implementación hace que el token se transfiera de su billetera a su billetera al reclamar, no del contrato.

La función de transfer en ERC20 enviará desde msg.sender a la dirección especificada. Entonces, en este caso, está transfiriendo de msg.sender a msg.sender .

La implementación correcta debería ser así,

 function claimFreeToken() public payable { _transfer(address(this), msg.sender, 1000 * (10**decimals())); }

Leer más: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol#L113

about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!