Tokens

我可以使用 Infura 獲取令牌詳細資訊嗎?

  • March 5, 2020

我瀏覽了https://infura.io/docs但不確定 Infura 是否可以讓我讀取令牌詳細資訊,例如所有者、令牌 ID 等。我還搜尋瞭如何使用 Infura 讀取令牌,但無濟於事。

有人試過嗎?

這是一個展示,可讓您以程式方式從區塊鏈中提取 NFT 數據:

https://github.com/cryptogoth/demo-erc721

例如,一些 Devcon5 門票以 NFT 的形式出售 https://etherscan.io/token/0x22cc8b3666e926bcbf58cb726143b2b044c80a0c?a=3441017121274051824038254820103043627286231148217420305072171742328

使用展示,您可以在http://erc721.org呼叫 ERC721 ABI 中的任何方法

特別是,呼叫ownerOf上面的令牌 ID 會給出:

NFT Owner is {"0":"0x66040374e443ae3e25afef08a781c4c2d175f43c"}

有一個手動步驟可以創建/添加一個空的乙太坊賬戶,然後您可以使用它來呼叫需要 gas 的 mutator 方法。我也在努力從命令行展示自動化這一步。希望對您有所幫助,歡迎提問和回饋。

試試這個:

const Web3 = require("web3");

async function run() {
   const web3 = new Web3("https://mainnet.infura.io/v3/" + YOUR_INFURA_PROJECT_ID);
   const contract = new web3.eth.Contract(YOUR_CONTRACT_ABI, YOUR_CONTRACT_ADDRESS);
   const retVal = await contract.methods.somePureOrViewFunction(arg1, arg2).call();
   const varVal = await contract.methods.somePublicVariable().call();
}

run();

引用自:https://ethereum.stackexchange.com/questions/76302