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

232
Views
Contrato ERC721 usando token ERC20 ignorado en _safeMint

Estoy tratando de realizar un _safeMint en javascript, pero se ignora el token ERC20. En cambio, el valor establecido se ve como el token de la red de prueba BSC, también conocido como BNB.

El uso del token ERC20 por contrato está aprobado para la billetera de los usuarios.

Entonces, en lugar de decirle al comprador que tiene que pagar 1 USDT y alguna tarifa de gas (BNB), dice que quiere retirar la cantidad de "1+tarifa de gas" BNB.

me estoy rascando la cabeza con este tema...

Mi código javascript para realizar _safeMint

 async function request_accounts() { console.log ("before await 1") provider = await get_provider(); await provider.send("eth_requestAccounts", []); const signer = provider.getSigner(); return signer; } async function connect_contract(){ signer = await request_accounts(); contract = new ethers.Contract(contractAddress, abi, signer); return contract; } async function buy_NFT() { console.log("before_buy_NFT"); contract = await connect_contract(); var test2 = await contract.safeMint("Wallet_address", "teststring", {value: ethers.utils.parseEther("1"), gasLimit: 50000,nonce: undefined}); console.log("after_buy_NFT"); }

Tengo el siguiente código de Solidity para mi contrato inteligente:

 pragma solidity ^0.8.15; import "@openzeppelin/contracts@4.6.0/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts@4.6.0/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts@4.6.0/token/ERC721/extensions/ERC721URIStorage.sol"; import "@openzeppelin/contracts@4.6.0/access/Ownable.sol"; import "@openzeppelin/contracts@4.6.0/utils/Counters.sol"; import "@openzeppelin/contracts@4.6.0/utils/cryptography/ECDSA.sol"; import "@openzeppelin/contracts@4.6.0/utils/cryptography/draft-EIP712.sol"; contract test is ERC721, EIP712, ERC721URIStorage, Ownable { using Counters for Counters.Counter; Counters.Counter private _tokenIdCounter; uint256 rate = 1 * 10 **18; // 1 USDT IERC20 public tokenAddress; constructor(address _tokenAddress) ERC721("test", "test") EIP712(SIGNING_DOMAIN, SIGNATURE_VERSION) { tokenAddress = IERC20(_tokenAddress); } function safeMint(address to, string memory uri) payable public { require(msg.value >= rate, "Please increase your USDT amount. Please check the ticket price"); tokenAddress.transferFrom(msg.sender, address(this), rate); uint256 tokenId = _tokenIdCounter.current(); _tokenIdCounter.increment(); _safeMint(to, tokenId); _setTokenURI(tokenId, uri); }
about 4 years ago · Juan Pablo Isaza
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!