web3.js手册

web3
web3.isConnected web3.setProvider web3.currentProvider web3.reset web3.sha3 web3.toHex web3.toAscii web3.fromAscii web3.toDecimal web3.fromDecimal web3.fromWei web3.toWei web3.toBigNumber web3.isAddress
web3.version
web3.version.api web3.version.node web3.version.network web3.version.ethereum web3.version.whisper
web3.net
web3.net.listening web3.net.peerCount
web3.shh
web3.shh.post web3.shh.newIdentity web3.shh.hasIdentity web3.shh.newGroup web3.shh.addGroup web3.shh.filter
web3.db
web3.db.putString web3.db.getString web3.db.putHex web3.db.getHex
web3.eth
web3.eth.defaultAccount web3.eth.defaultBlock web3.eth.syncing web3.eth.isSyncing web3.eth.coinbase web3.eth.hashrate web3.eth.gasPrice web3.eth.accounts web3.eth.mining web3.eth.blockNumber web3.eth.register web3.eth.unRegister web3.eth.getBalance web3.eth.getStorageAt web3.eth.getCode web3.eth.getBlock web3.eth.getBlockTransactionCount web3.eth.getUncle web3.eth.getBlockUncleCount web3.eth.getTransaction web3.eth.getTransactionFromBlock web3.eth.getTransactionReceipt web3.eth.getTransactionCount web3.eth.sendTransaction web3.eth.sendRawTransaction web3.eth.sign web3.eth.call web3.eth.estimateGas web3.eth.filter web3.eth.Contract web3.eth.namereg
iban
web3.eth.sendIBANTransaction web3.eth.iban web3.eth.iban.fromAddress web3.eth.iban.fromBban web3.eth.iban.createIndirect web3.eth.iban.isValid web3.eth.iban.isDirect web3.eth.iban.isIndirect web3.eth.iban.checksun web3.eth.iban.institution web3.eth.iban.client web3.eth.iban.address web3.eth.iban.toString
compiler
web3.eth.getCompilers web3.eth.compile.solidity web3.eth.compile.lll web3.eth.compile.serpent
在线工具推荐: Three.js AI纹理开发包 - YOLO合成数据生成器 - GLTF/GLB在线编辑 - 3D模型格式在线转换 - 可编程3D场景编辑器

web3.eth.getTransaction

返回匹配指定交易哈希值的交易。

调用:

web3.eth.getTransaction(transactionHash [, callback])

参数:

  • transactionHash: String - 交易的哈希值。
  • callback: Function - 回调函数,用于支持异步的方式执行7。

返回值:

  • Object - 一个交易对象
    • hash: String - 32字节,交易的哈希值。
    • nonce: Number - 交易的发起者在之前进行过的交易数量。
    • blockHash: String - 32字节。交易所在区块的哈希值。当这个区块处于pending将会返回null。
    • blockNumber: Number - 交易所在区块的块号。当这个区块处于pending将会返回null。
    • transactionIndex: Number - 整数。交易在区块中的序号。当这个区块处于pending将会返回null。
    • from: String - 20字节,交易发起者的地址。
    • to: String - 20字节,交易接收者的地址。当这个区块处于pending将会返回null。
    • value: BigNumber - 交易附带的货币量,单位为Wei。
    • gasPrice: BigNumber - 交易发起者配置的gas价格,单位是wei。
    • gas: Number - 交易发起者提供的gas。.
    • input: String - 交易附带的数据。

示例:

var blockNumber = 668;
var indexOfTransaction = 0

var transaction = web3.eth.getTransaction(blockNumber, indexOfTransaction);
console.log(transaction);
/*
{
  "hash": "0x9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b",
  "nonce": 2,
  "blockHash": "0xef95f2f1ed3ca60b048b4bf67cde2195961e0bba6f70bcbea9a2c4e133e34b46",
  "blockNumber": 3,
  "transactionIndex": 0,
  "from": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b",
  "to": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f",
  "value": BigNumber,
  "gas": 314159,
  "gasPrice": BigNumber,
  "input": "0x57cb2fc4"
}
*/