BlockchainTransactionSign (for Ethereum)
BlockchainTransactionSign[obj,key]
用指定的私钥对以太坊区块链交易进行数字签名.
更多信息
- 在 BlockchainTransactionSign[obj,…] 中,obj 是一个 BlockchainTransaction 对象.
- BlockchainTransactionSign 的密钥必须是 PrivateKey 对象或表示私钥的十六进制字符串.
- BlockchainTransactionSign 返回一个区块链交易对象,其属性 "Signed" 的值为 True,并同时具有附加属性 "RawTransaction".
范例
打开所有单元 关闭所有单元基本范例 (1)
创建一个以太坊 BlockchainTransaction:
ethTX = BlockchainTransaction[<|"BlockchainBase" -> {"Ethereum", "Testnet"},
"TransactionCount" -> 11,
"GasPrice" -> Quantity[150, "GWei"],
"Address" -> "61cccDcDb7617d01239D0Cfc7D1627e39EA2a2c3",
"Amount" -> Quantity[0.50, "Ethers"]|>]BlockchainTransactionSign[ethTX, PrivateKey[Association["Type" -> "EllipticCurve", "CurveName" -> "secp256k1",
"PublicCurvePoint" ->
{16676173248318435135530093705658075451448270649776782441185582813615674064589,
86146693258001150152237806044792681696883435827253397319 ... 84,
"Compressed" -> False, "PublicByteArray" ->
ByteArray[
"BCTeYSvTb1h4i8B8nUtJrM//zRHHu7GdlW16oP8LZ37NvnVM7PCJ8Qms/BwonG76LAj2PCP+VGbfyw1cFM21dNI="],
"PrivateByteArray" -> ByteArray["q/aGR9Z8/pp7h2fSVcu50AHSi8r4pHPKW97/exaY34w="]]]]应用 (1)
创建一个以太坊 BlockchainTransaction:
ethTX = BlockchainTransaction[<|"BlockchainBase" -> {"Ethereum", "Testnet"},
"TransactionCount" -> 11,
"GasPrice" -> Quantity[150, "GWei"],
"Address" -> "61cccDcDb7617d01239D0Cfc7D1627e39EA2a2c3",
"Amount" -> Quantity[0.50, "Ethers"]|>]ethTXSigned = BlockchainTransactionSign[ethTX, PrivateKey[Association["Type" -> "EllipticCurve", "CurveName" -> "secp256k1",
"PublicCurvePoint" ->
{16676173248318435135530093705658075451448270649776782441185582813615674064589,
86146693258001150152237806044792681696883435827253397319 ... 84,
"Compressed" -> False, "PublicByteArray" ->
ByteArray[
"BCTeYSvTb1h4i8B8nUtJrM//zRHHu7GdlW16oP8LZ37NvnVM7PCJ8Qms/BwonG76LAj2PCP+VGbfyw1cFM21dNI="],
"PrivateByteArray" -> ByteArray["q/aGR9Z8/pp7h2fSVcu50AHSi8r4pHPKW97/exaY34w="]]]]ethTXSubmit = BlockchainTransactionSubmit[ethTXSigned]txdata = BlockchainTransactionData[ethTXSubmit["TransactionID"], BlockchainBase -> {"Ethereum", "Testnet"}]可能存在的问题 (1)
不正确的私钥 (1)
如果提供了无效的私钥,将返回 $Failed:
tx = BlockchainTransaction[Association["BlockchainBase" -> {"Ethereum", "TestNet"}, "Signed" -> False,
"TransactionCount" -> 58, "GasPrice" -> Quantity[1, "Gwei"], "GasLimit" -> 25200,
"Fee" -> Quantity[25200000000000, "Wei"],
"Address" -> "3535353535353535353535353535353535353535", "Amount" -> Quantity[0.0002, "Ethers"],
"MessageHash" -> "beac3f99c4d488b97866f84b96caf8fa2415bbfbab0d554ed1a507bc888e7638"]];BlockchainTransactionSign[tx, "AAAAAA"]相关指南
-
▪
- 使用以太坊区块链
历史
2019年引入 (12.0)
文本
Wolfram Research (2019),BlockchainTransactionSign,Wolfram 语言函数,https://reference.wolfram.com/language/ref/blockchain/BlockchainTransactionSign-Ethereum.html.
CMS
Wolfram 语言. 2019. "BlockchainTransactionSign." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/blockchain/BlockchainTransactionSign-Ethereum.html.
APA
Wolfram 语言. (2019). BlockchainTransactionSign. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/blockchain/BlockchainTransactionSign-Ethereum.html 年
BibTeX
@misc{reference.wolfram_2026_blockchaintransactionsign, author="Wolfram Research", title="{BlockchainTransactionSign}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/blockchain/BlockchainTransactionSign-Ethereum.html}", note=[Accessed: 13-September-2026]}
BibLaTeX
@online{reference.wolfram_2026_blockchaintransactionsign, organization={Wolfram Research}, title={BlockchainTransactionSign}, year={2019}, url={https://reference.wolfram.com/language/ref/blockchain/BlockchainTransactionSign-Ethereum.html}, note=[Accessed: 13-September-2026]}