Geth管理API文档

admin
admin_addPeer:添加远程节点 admin_datadir:获取链库数据目录 admin_nodeInfo:获取节点信息 admin_peers:获取远程节点列表 admin_setSolc:设置solidity编译器路径 admin_startRPC:启动HTTP RPC服务 admin_startWS:启动WebSocket RPC服务 admin_stopRPC:停止HTTP RPC服务 admin_stopWS:停止WebSocket RPC服务
debug
debug_backtraceAt:设置回溯跟踪位置 debug_blockProfile:启用限时区块性能检测 debug_cpuProfile:启用限时CPU性能检测 debug_dumpBlock:导出指定区块 debug_gcStats:获取GC统计信息 debug_getBlockRlp:获取指定区块RPL编码数据 debug_goTrace:启用限时go运行时跟踪 debug_memStats:返回运行时内存统计 debug_seedHash:提取指定区块种子哈希 debug_setBlockProfileRate:设置区块性能检测速率 debug_setHead:设置本地链头区块 debug_stacks:返回go协程调用栈 debug_startCPUProfile:启用PCU性能检测 debug_startGoTrace:启用go运行时跟踪 debug_stopGoTrace:停止go运行时跟踪 debug_traceBlock:返回区块操作码调用栈 debug_traceBlockByNumber:返回指定序号区块调用栈 debug_traceBlockByHash:返回指定哈希区块调用栈 debug_traceBlockFromFile:返回指定区块文件调用栈 debug_traceTransaction:交易模拟跟踪 debug_verbosity:设置日志输出级别 debug_vmodule:设置日志可视模式 debug_writeBlockProfile:保存区块性能检测数据 debug_writeMemProfile:保存内存性能检测数据
miner
miner_setExtra:设置区块挖矿额外数据 miner_setGasPrice:设置gas价格下限 miner_start:启动CPU挖矿 miner_stop:停止CPU挖矿 miner_getHashrate:获取哈希生成速率 miner_setEtherBase:设置挖矿收益账户
personal
personal_importRawKey:导入私钥 personal_listAccounts:获取账户清单 personal_lockAccount:锁定账户 personal_newAccount:创建新账户 personal_unlockAccount:解锁账户 personal_sendTransaction:发送交易 personal_sign:消息签名 personal_ecRecover:提取签名中的发起账户
txpool
txpool_content:获取池内交易详情 txpool_inspect:获取池内交易概况 txpool_status:获取交易状态
在线工具推荐: Three.js AI纹理开发包 - YOLO合成数据生成器 - GLTF/GLB在线编辑 - 3D模型格式在线转换 - 可编程3D场景编辑器

personal_sendTransaction

sendTransaction方法验证指定的密码并提交交易,该方法的交易参数 与eth_sendTransaction一样,同时包含from账户地址。

如果密码可以成功解密交易中from地址对应的私钥,那么该方法将验证交易、 签名并广播到以太坊网络中。

由于在sendTransaction方法调用时,from账户并未在节点中全局解锁 (仅在该调用内解锁),因此from账户不能用于其他RPC调用。

调用方法

Geth控制台:

personal.sendTransaction(tx, passphrase)

JSON RPC:

{"method": "personal_sendTransaction", "params": [tx, string]}

注意,在Geth1.5之前的版本,请使用personal_signAndSendtransaction方法。

示例代码

下面的示例在Geth控制台使用sendTransaction方法提交交易:

> var tx = {from: "0x391694e7e0b0cce554cb130d723a9d27458f9298", to: "0xafa3f8684e54059998bc3a7b0d2b0da075154d66", value: web3.toWei(1.23, "ether")}
undefined
> personal.sendTransaction(tx, "passphrase")
0x8474441674cdd47b35b875fd1a530b800b51a5264b9975fb21129eeb8c18582f