runContractFunction
運行合約 ABI 的給定函數(shù)并返回只讀數(shù)據(jù)(異步)。
選項:
chain
?(可選):從中獲取數(shù)據(jù)的區(qū)塊鏈。 有效值列在支持的鏈上。 默認(rèn)值 Eth。function_name
?(必填):函數(shù)名address
?(必填):一個智能合約地址abi
?(必填):合約或函數(shù) ABI(應(yīng)作為數(shù)組提供)params
?(可選):特定功能所需的參數(shù)你可以通過?JS
?、?React
?、?curl
?、?Unity
?來實現(xiàn)
const ABI = []; // Add ABI of 0xdAC17F958D2ee523a2206206994597C13D831ec7
const options = {
chain: "eth",
address: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
function_name: "balanceOf",
abi: ABI,
params: { who: "0x3355d6E71585d4e619f4dB4C7c5Bfe549b278299" },
};
const allowance = await Moralis.Web3API.native.runContractFunction(options);
import React from "react";
import { useMoralisWeb3Api } from "react-moralis";
const GetAddressBalanceOfUSDT = () => {
// 0xdAC17F958D2ee523a2206206994597C13D831ec7 = contract address of USDT
const { native } = useMoralisWeb3Api();
const ABI = []; // Add ABI of 0xdAC17F958D2ee523a2206206994597C13D831ec7
const options = {
chain: "eth",
address: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
function_name: "balanceOf",
abi: ABI,
params: { who: "0x3355d6E71585d4e619f4dB4C7c5Bfe549b278299" },
};
const { fetch, data, error, isLoading } = useMoralisWeb3ApiCall(
native.runContractFunction,
{ ...options }
);
return (
// Use your custom error component to show errors
<div style={{ height: "100vh", overflow: "auto" }}>
<div>
{error && <ErrorMessage error={error} />}
<button
onClick={() => {
fetch({ params: options });
}}
>
Fetch data
</button>
{data && <pre>{JSON.stringify(data)}</pre>}
</div>
</div>
);
};
curl -X 'POST' \
'https://deep-index.moralis.io/api/v2/0xdAC17F958D2ee523a2206206994597C13D831ec7/function?chain=eth&function_name=balanceOf' \
-H 'accept: application/json' \
-H 'X-API-Key: MY-API-KEY' \
-H 'Content-Type: application/json' \
-d '{
"abi": MY-CONTRACT-ABI ,
"params": {"who": "0x3355d6E71585d4e619f4dB4C7c5Bfe549b278299" }
}'
using System.Collections.Generic;
using Moralis.Web3Api.Models;
using MoralisWeb3ApiSdk;
public async void ReadFunction()
{
// Function ABI input parameters
object[] inputParams = new object[1];
inputParams[0] = new { internalType = "address", name = "account", type = "address"};
// Function ABI Output parameters
object[] outputParams = new object[1];
outputParams[0] = new { internalType = "uint256", name = "", type = "uint256"};
// Function ABI
object[] abi = new object[1];
abi[0] = new { inputs = inputParams, name = "balanceOf", outputs = outputParams, stateMutability = "view", type = "function" };
// Define request object
RunContractDto rcd = new RunContractDto()
{
Abi = abi,
Params = new { account = "0x3355d6E71585d4e619f4dB4C7c5Bfe549b278299" }
};
string resp = await MoralisInterface.GetClient().Web3Api.Native.RunContractFunction("0xdAC17F958D2ee523a2206206994597C13D831ec7", "balanceOf", rcd, ChainList.eth);
print(resp);
}
示例結(jié)果:
{"result":"5691150038"}
通過塊哈希檢索塊的內(nèi)容。 返回一個塊對象(異步)。
選項:
chain
?(可選):從區(qū)塊鏈獲取數(shù)據(jù)。 有效值列在支持的鏈上。 默認(rèn)值 Eth。
block_number_or_hash
?(必需):塊哈希或塊號。你可以通過?JS
?、?React
?、?curl
?、?Unity
?來實現(xiàn)
const options = { chain: "bsc", block_number_or_hash: "2" };
// get block content on BSC
const transactions = await Moralis.Web3API.native.getBlock(options);
import React from "react";
import { useMoralisWeb3Api } from "react-moralis";
const Web3Api = useMoralisWeb3Api();
// get block content on BSC
const fetchBlock = async () => {
const options = { chain: "bsc", block_number_or_hash: "2" };
const result = await Web3Api.native.getBlock(options);
console.log(result);
};
curl -X 'GET' \
'https://deep-index.moralis.io/api/v2/block/2?chain=bsc' \
-H 'accept: application/json' \
-H 'X-API-Key: MY-API-KEY'
using System.Collections.Generic;
using Moralis.Web3Api.Models;
using MoralisWeb3ApiSdk;
public async void fetchBlock()
{
Block block = await MoralisInterface.GetClient().Web3Api.Native.GetBlock(blockNumberOrHash: "2", ChainList.bsc);
print(block.ToJson());
}
示例結(jié)果:
{
"timestamp": "2021-05-07T11:08:35.000Z",
"number": "12386788",
"hash": "0x9b559aef7ea858608c2e554246fe4a24287e7aeeb976848df2b9a2531f4b9171",
"parent_hash": "0x011d1fc45839de975cc55d758943f9f1d204f80a90eb631f3bf064b80d53e045",
"nonce": "0xedeb2d8fd2b2bdec",
"sha3_uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"logs_bloom": "0xdde5fc46c5d8bcbd58207bc9f267bf43298e23791a326ff02661e99790da9996b3e0dd912c0b8202d389d282c56e4d11eb2dec4898a32b6b165f1f4cae6aa0079498eab50293f3b8defbf6af11bb75f0408a563ddfc26a3323d1ff5f9849e95d5f034d88a757ddea032c75c00708c9ff34d2207f997cc7d93fd1fa160a6bfaf62a54e31f9fe67ab95752106ba9d185bfdc9b6dc3e17427f844ee74e5c09b17b83ad6e8fc7360f5c7c3e4e1939e77a6374bee57d1fa6b2322b11ad56ad0398302de9b26d6fbfe414aa416bff141fad9d4af6aea19322e47595e342cd377403f417dfd396ab5f151095a5535f51cbc34a40ce9648927b7d1d72ab9daf253e31daf",
"transactions_root": "0xe4c7bf3aff7ad07f9e80d57f7189f0252592fee6321c2a9bd9b09b6ce0690d27",
"state_root": "0x49e3bfe7b618e27fde8fa08884803a8458b502c6534af69873a3cc926a7c724b",
"receipts_root": "0x7cf43d7e837284f036cf92c56973f5e27bdd253ca46168fa195a6b07fa719f23",
"miner": "0xea674fdde714fd979de3edf0f56aa9716b898ec8",
"difficulty": "7253857437305950",
"total_difficulty": "24325637817906576196890",
"size": "61271",
"extra_data": "0x65746865726d696e652d6575726f70652d7765737433",
"gas_limit": "14977947",
"gas_used": "14964688",
"transaction_count": "252",
"transactions": [
{
"hash": "0x1ed85b3757a6d31d01a4d6677fc52fd3911d649a0af21fe5ca3f886b153773ed",
"nonce": "1848059",
"transaction_index": "108",
"from_address": "0x267be1c1d684f78cb4f6a176c4911b741e4ffdc0",
"to_address": "0x003dde3494f30d861d063232c6a8c04394b686ff",
"value": "115580000000000000",
"gas": "30000",
"gas_price": "52500000000",
"input": "0x",
"receipt_cumulative_gas_used": "4923073",
"receipt_gas_used": "21000",
"receipt_contract_address": null,
"receipt_root": null,
"receipt_status": "1",
"block_timestamp": "2021-05-07T11:08:35.000Z",
"block_number": "12386788",
"block_hash": "0x9b559aef7ea858608c2e554246fe4a24287e7aeeb976848df2b9a2531f4b9171",
"logs": [
{
"log_index": "273",
"transaction_hash": "0xdd9006489e46670e0e85d1fb88823099e7f596b08aeaac023e9da0851f26fdd5",
"transaction_index": "204",
"address": "0x3105d328c66d8d55092358cf595d54608178e9b5",
"data": "0x00000000000000000000000000000000000000000000000de05239bccd4d537400000000000000000000000000024dbc80a9f80e3d5fc0a0ee30e2693781a443",
"topic0": "0x2caecd17d02f56fa897705dcc740da2d237c373f70686f4e0d9bd3bf0400ea7a",
"topic1": "0x000000000000000000000000031002d15b0d0cd7c9129d6f644446368deae391",
"topic2": "0x000000000000000000000000d25943be09f968ba740e0782a34e710100defae9",
"topic3": null,
"block_timestamp": "2021-05-07T11:08:35.000Z",
"block_number": "12386788",
"block_hash": "0x9b559aef7ea858608c2e554246fe4a24287e7aeeb976848df2b9a2531f4b9171"
}
]
}
]
}
檢索提供日期的最近塊(異步)。
選項:
chain
?(可選):從中獲取數(shù)據(jù)的區(qū)塊鏈。 有效值列在支持的鏈上。 默認(rèn)值 Eth。
date
?(必需):以毫秒為單位的 ?Unix
?日期或日期字符串(?momentjs
?接受的任何格式)你可以使用?JS
?、?React
?、?curl
?、?Unity
?來實現(xiàn)
const options = {
chain: "bsc",
date: "2021-09-29T13:09:15+00:00",
};
const date = await Moralis.Web3API.native.getDateToBlock(options);
import React from "react";
import { useMoralisWeb3Api } from "react-moralis";
const Web3Api = useMoralisWeb3Api();
const fetchDateToBlock = async () => {
const options = { chain: "bsc", date: "2021-09-29T13:09:15+00:00" };
const date = await Web3Api.native.getDateToBlock(options);
console.log(date);
};
curl -X 'GET' \
'https://deep-index.moralis.io/api/v2/dateToBlock?chain=bsc&date=2021-09-29T13%3A09%3A15%2B00%3A00' \
-H 'accept: application/json' \
-H 'X-API-Key: MY-API-KEY'
using System.Collections.Generic;
using Moralis.Web3Api.Models;
using MoralisWeb3ApiSdk;
public async void fetchDateToBlock()
{
BlockDate blockDate = await MoralisInterface.GetClient().Web3Api.Native.GetDateToBlock(date:"2021-09-29T13:09:15+00:00", ChainList.eth);
print(blockDate.ToJson());
}
示例結(jié)果:
{
"date": "2020-01-01T00:00:00+00:00",
"block": 9193266,
"timestamp": 1577836811
}
從地址檢索日志(異步)。
選項:
chain
?(可選):從中獲取數(shù)據(jù)的區(qū)塊鏈。有效值列在支持的鏈上。默認(rèn)值 Eth。
from_date
?(可選):獲取交易的日期(momentjs 接受的任何格式)。提供參數(shù) 'from_block' 或 'from_date' 如果提供了 'from_date' 和 'from_block',則將使用 'from_block'。
to_date
?(可選):獲取到此日期的交易(momentjs 接受的任何格式)。提供參數(shù) 'to_block' 或 'to_date' 如果提供了 'to_date' 和 'to_block',將使用 'to_block'。
from_block
?(可選):從哪里獲取交易的最小塊號提供參數(shù)'from_block'或'from_date'如果提供'from_date'和'from_block',將使用'from_block'。
to_block
?(可選):從哪里獲取交易的最大塊號。提供參數(shù) 'to_block' 或 'to_date' 如果提供了 'to_date' 和 'to_block',將使用 'to_block'。
address
?(必填):智能合約地址
topic0
?(可選):事件主題
topic1
?(可選):事件主題
topic2
?(可選):事件主題
topic3
?(可選):事件主題你可以使用?JS
?、?React
?、?curl
?、?Unity
?來實現(xiàn)
const options = {
address: "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
chain: "bsc",
topic0: "0x2caecd17d02f56fa897705dcc740da2d237c373f70686f4e0d9bd3bf0400ea7a",
topic1: "0x000000000000000000000000031002d15b0d0cd7c9129d6f644446368deae391",
topic2: "0x000000000000000000000000d25943be09f968ba740e0782a34e710100defae9",
};
const logs = await Moralis.Web3API.native.getLogsByAddress(options);
import React from "react";
import { useMoralisWeb3Api } from "react-moralis";
const Web3Api = useMoralisWeb3Api();
const fetchLogsByAddress = async () => {
const options = {
address: "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
chain: "bsc",
topic0:
"0x2caecd17d02f56fa897705dcc740da2d237c373f70686f4e0d9bd3bf0400ea7a",
topic1:
"0x000000000000000000000000031002d15b0d0cd7c9129d6f644446368deae391",
topic2:
"0x000000000000000000000000d25943be09f968ba740e0782a34e710100defae9",
};
const logs = await Web3Api.native.getLogsByAddress(options);
console.log(logs);
};
curl -X 'GET' \
'https://deep-index.moralis.io/api/v2/0x057Ec652A4F150f7FF94f089A38008f49a0DF88e/logs?chain=bsc&topic0=0x2caecd17d02f56fa897705dcc740da2d237c373f70686f4e0d9bd3bf0400ea7a&topic1=0x000000000000000000000000031002d15b0d0cd7c9129d6f644446368deae391&topic2=0x000000000000000000000000d25943be09f968ba740e0782a34e710100defae9' \
-H 'accept: application/json' \
-H 'X-API-Key: MY-API-KEY'
using System.Collections.Generic;
using Moralis.Web3Api.Models;
using MoralisWeb3ApiSdk;
public async void fetchLogsByAddress()
{
LogEventByAddress logEvents = await MoralisInterface.GetClient().Web3Api.Native.GetLogsByAddress(address: "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e", ChainList.bsc, topic0:"0x2caecd17d02f56fa897705dcc740da2d237c373f70686f4e0d9bd3bf0400ea7a",topic1:"0x000000000000000000000000031002d15b0d0cd7c9129d6f644446368deae391", topic2:"0x000000000000000000000000d25943be09f968ba740e0782a34e710100defae9");
print(logEvents.ToJson());
}
示例結(jié)果:
{
"transaction_hash": "0x2d30ca6f024dbc1307ac8a1a44ca27de6f797ec22ef20627a1307243b0ab7d09",
"address": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
"block_timestamp": "2021-04-02T10:07:54.000Z",
"block_number": "12526958",
"block_hash": "0x0372c302e3c52e8f2e15d155e2c545e6d802e479236564af052759253b20fd86",
"data": "0x00000000000000000000000000000000000000000000000de05239bccd4d537400000000000000000000000000024dbc80a9f80e3d5fc0a0ee30e2693781a443",
"topic0": "0x2caecd17d02f56fa897705dcc740da2d237c373f70686f4e0d9bd3bf0400ea7a",
"topic1": "0x000000000000000000000000031002d15b0d0cd7c9129d6f644446368deae391",
"topic2": "0x000000000000000000000000d25943be09f968ba740e0782a34e710100defae9",
"topic3": null
}
根據(jù)塊號按降序獲取事件。 返回一個包含 ?Contract
?事件數(shù)量和 ?Contract
?事件數(shù)組(異步)的對象。
選項:
chain
?(可選):從中獲取數(shù)據(jù)的區(qū)塊鏈。 有效值列在支持的鏈上。 默認(rèn)值 Eth。
offset
?(可選):偏移量。
limit
?(可選):限制。
from_block
?(可選):從該區(qū)塊開始獲取合約事件
to_block
?(可選):獲取此區(qū)塊的合約事件
topic
?(必填):活動的主題
address
?(必填):一個智能合約地址
abi
?(必填):事件ABI(不插入整個智能合約的ABI)。 ABI 具有 JSON 格式。你可以使用?JS
?、?React
?、?curl
?、?Unity
?來實現(xiàn)
const ABI = {
anonymous: false,
inputs: [
{ indexed: true, name: "from", type: "address" },
{ indexed: true, name: "to", type: "address" },
{ indexed: false, name: "value", type: "uint256" },
],
name: "Transfer",
type: "event",
};
const options = {
chain: "eth",
address: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
topic: "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
limit: "3",
abi: ABI,
};
const events = await Moralis.Web3API.native.getContractEvents(options);
import React from "react";
import { useMoralisWeb3Api } from "react-moralis";
const Web3Api = useMoralisWeb3Api();
const ABI = {
anonymous: false,
inputs: [
{ indexed: true, name: "from", type: "address" },
{ indexed: true, name: "to", type: "address" },
{ indexed: false, name: "value", type: "uint256" },
],
name: "Transfer",
type: "event",
};
const fetchContractEvents = async () => {
const options = {
chain: "eth",
address: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
topic: "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
limit: "3",
abi: ABI,
};
const events = await Web3Api.native.getContractEvents(options);
console.log(events);
};
curl -X 'POST' \
'https://deep-index.moralis.io/api/v2/0xdAC17F958D2ee523a2206206994597C13D831ec7/events?chain=eth&topic=0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef&limit=3' \
-H 'accept: application/json' \
-H 'X-API-Key: MY-API-KEY' \
-H 'Content-Type: application/json' \
-d '{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"}'
using System.Collections.Generic;
using Moralis.Web3Api.Models;
using MoralisWeb3ApiSdk;
public async void fetchContractEvents()
{
string abi = "{anonymous: false, inputs:[{ indexed: true, name: \"from\", type: \"address\" },{ indexed: true, name: \"to\", type: \"address\" },{ indexed: false, name: \"value\", type: \"uint256\" },],name: \"Transfer\", type: \"event\" }";
List<LogEvent> logEvents = await MoralisInterface.GetClient().Web3Api.Native.GetContractEvents(address: "0xdAC17F958D2ee523a2206206994597C13D831ec7", topic: "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",abi: abi, ChainList.eth);
foreach (LogEvent eventlog in logEvents)
{
print(eventlog.ToJson());
}
}
示例結(jié)果:
{
"total": 140209404,
"page": 0,
"page_size": 3,
"result": [
{
"transaction_hash": "0xc9f62f4f6ab505a96c1a84ec2899c6bfd86245ef1effaa689fc997798be763d5",
"address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"block_timestamp": "2022-03-05T13:45:42.000Z",
"block_number": "14327217",
"block_hash": "0x1bb168d2725d15b12604c92a83c529617cd54a415c5d610a687f7859d45f9ea5",
"data": {
"from": "0x21f510cc9f81df4e4d2c705e672761cf487cdc5a",
"to": "0x54e41aa7ac19efd71d19a3ca6b8a6c0154fe3afb",
"value": "878000000"
}
},
{
"transaction_hash": "0x5ca80d7c49472072f5b98726b9cecd7f3d47e8a467c7a687339c3ba0471107e7",
"address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"block_timestamp": "2022-03-05T13:45:42.000Z",
"block_number": "14327217",
"block_hash": "0x1bb168d2725d15b12604c92a83c529617cd54a415c5d610a687f7859d45f9ea5",
"data": {
"from": "0x63f12a6b5a21484c70cd78ef0df411c23c3adf87",
"to": "0x391838e4418e6ebaefa494c433c596b5705b27f5",
"value": "50000000000"
}
},
{
"transaction_hash": "0x69af21043e167483cb99660f097da9a4f65296d7ec5b40687afc9eadeefeb868",
"address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"block_timestamp": "2022-03-05T13:45:42.000Z",
"block_number": "14327217",
"block_hash": "0x1bb168d2725d15b12604c92a83c529617cd54a415c5d610a687f7859d45f9ea5",
"data": {
"from": "0x7012e425e473feecd61543d8d31b2f51b57018fc",
"to": "0xbd578df89c458b1cc60d7afca2f960831cd820a2",
"value": "321600000"
}
}
]
}
按塊號或塊哈希檢索 NFT 傳輸。 返回一個 NFT 傳輸數(shù)組(異步)。
選項:
chain
?(可選):從中獲取數(shù)據(jù)的區(qū)塊鏈。 有效值列在支持的鏈上。 默認(rèn)值 Eth。
block_number_or_hash
?(必需):塊哈希或塊號。你可以使用?JS
?、?React
?、?curl
?、?Unity
?來實現(xiàn)
const options = { chain: "bsc", block_number_or_hash: "11284830" };
// get NFT transfers by block number or block hash
const NFTTransfers = await Moralis.Web3API.native.getNFTTransfersByBlock(
options
);
import React from "react";
import { useMoralisWeb3Api } from "react-moralis";
const Web3Api = useMoralisWeb3Api();
const fetchNFTTransfersByBlock = async () => {
// get NFT transfers by block number or block hash
const options = { chain: "bsc", block_number_or_hash: "11284830" };
const NFTTransfers = await Web3Api.native.getNFTTransfersByBlock(options);
console.log(NFTTransfers);
};
curl -X 'GET' \
'https://deep-index.moralis.io/api/v2/block/11284830/nft/transfers?chain=bsc&limit=500' \
-H 'accept: application/json' \
-H 'X-API-Key: MY-API-KEY'
using System.Collections.Generic;
using Moralis.Web3Api.Models;
using MoralisWeb3ApiSdk;
public async void fetchNFTTransfersByBlock()
{
NftTransferCollection nftTransfers = MoralisInterface.GetClient().Web3Api.Native.GetNFTTransfersByBlock(blockNumberOrHash: "11284830", ChainList.bsc);
print(nftTransfers.ToJson());
}
示例結(jié)果:
[
{
amount: "1",
block_hash:
"0x4c00bcee8900e5fc4f6a5d11dff6edca3b97470da290986940da1d2f0ef221fb",
block_number: "11284830",
block_timestamp: "2021-09-27T17:07:54.000Z",
contract_type: "ERC721",
from_address: "0x6102f780a5c51dee8ce46c5db5b62d88119d559d",
log_index: 130,
to_address: "0xd95f7419ce0debf3a991ef9944808010928db319",
token_address: "0xcf58705e2ff8642c4276c2dd2747ec8af5bafc1d",
token_id: "281",
transaction_hash:
"0x19721cf6855f412f82de87f8c6050e6de3cc77a81388002bc24efea53bd36a0f",
transaction_index: 35,
transaction_type: "Single",
},
];
通過交易哈希獲取交易。 返回一個事務(wù)對象(異步)。
選項:
chain
?(可選):從中獲取數(shù)據(jù)的區(qū)塊鏈。 有效值列在支持的鏈上。 默認(rèn)值 Eth。
transaction_hash
?(必需):交易哈希。你可以使用?JS
?、?React
?、?curl
?、?Unity
?來實現(xiàn)
const options = {
chain: "eth",
transaction_hash:
"0x5e519cd5117aea6ed9d51d4f235b4badb2e3f69377a4e2f945e13feb20af4db3",
};
const transaction = await Moralis.Web3API.native.getTransaction(options);
import React from "react";
import { useMoralisWeb3Api } from "react-moralis";
const Web3Api = useMoralisWeb3Api();
const fetchTransaction = async () => {
const options = {
chain: "eth",
transaction_hash:
"0x5e519cd5117aea6ed9d51d4f235b4badb2e3f69377a4e2f945e13feb20af4db3",
};
const transaction = await Web3Api.native.getTransaction(options);
console.log(transaction);
};
curl -X 'GET' \
'https://deep-index.moralis.io/api/v2/transaction/0x5e519cd5117aea6ed9d51d4f235b4badb2e3f69377a4e2f945e13feb20af4db3?chain=eth' \
-H 'accept: application/json' \
-H 'X-API-Key: MY-API-KEY'
using System.Collections.Generic;
using Moralis.Web3Api.Models;
using MoralisWeb3ApiSdk;
public async void fetchTransaction()
{
BlockTransaction blockTransaction = MoralisInterface.GetClient().Web3Api.Native.GetTransaction(transactionHash:"0x5e519cd5117aea6ed9d51d4f235b4badb2e3f69377a4e2f945e13feb20af4db3", ChainList.eth);
print(blockTransaction.ToJson());
}
示例結(jié)果:
{
"hash": "0x1ed85b3757a6d31d01a4d6677fc52fd3911d649a0af21fe5ca3f886b153773ed",
"nonce": "1848059",
"transaction_index": "108",
"from_address": "0x267be1c1d684f78cb4f6a176c4911b741e4ffdc0",
"to_address": "0x003dde3494f30d861d063232c6a8c04394b686ff",
"value": "115580000000000000",
"gas": "30000",
"gas_price": "52500000000",
"input": "0x",
"receipt_cumulative_gas_used": "4923073",
"receipt_gas_used": "21000",
"receipt_contract_address": null,
"receipt_root": null,
"receipt_status": "1",
"block_timestamp": "2021-05-07T11:08:35.000Z",
"block_number": "12386788",
"block_hash": "0x9b559aef7ea858608c2e554246fe4a24287e7aeeb976848df2b9a2531f4b9171",
"logs": [
{
"log_index": "273",
"transaction_hash": "0xdd9006489e46670e0e85d1fb88823099e7f596b08aeaac023e9da0851f26fdd5",
"transaction_index": "204",
"address": "0x3105d328c66d8d55092358cf595d54608178e9b5",
"data": "0x00000000000000000000000000000000000000000000000de05239bccd4d537400000000000000000000000000024dbc80a9f80e3d5fc0a0ee30e2693781a443",
"topic0": "0x2caecd17d02f56fa897705dcc740da2d237c373f70686f4e0d9bd3bf0400ea7a",
"topic1": "0x000000000000000000000000031002d15b0d0cd7c9129d6f644446368deae391",
"topic2": "0x000000000000000000000000d25943be09f968ba740e0782a34e710100defae9",
"topic3": null,
"block_timestamp": "2021-05-07T11:08:35.000Z",
"block_number": "12386788",
"block_hash": "0x9b559aef7ea858608c2e554246fe4a24287e7aeeb976848df2b9a2531f4b9171"
}
]
}
更多建議: