今天來談談發送交易
之前就有提到區塊鏈就是一個公開帳本,我們可以將交易上傳上去經由驗證節點的共識驗證後添加到新的Block中,而將交易廣播至區塊鏈網路中的就是Full node,Full node收到提交交易請求後會廣播至網路中等待驗證節點打包交易並產生新的區塊,我們來看看Elrond文件中提交交易請求的內容,
request example:
POST https://gateway.elrond.com/transaction/send HTTP/1.1
Content-Type: application/json
{
"nonce": 42,
"value": "100000000000000000",
"receiver": "erd1cux02zersde0l7hhklzhywcxk4u9n4py5tdxyx7vrvhnza2r4gmq4vw35r",
"sender": "erd1njqj2zggfup4nl83x0nfgqjkjserm7mjyxdx5vzkm8k0gkh40ezqtfz9lg",
"gasPrice": 1000000000,
"gasLimit": 70000,
"data": "Zm9vZCBmb3IgY2F0cw==", #base64 representation of "food for cats"
"signature": "93207c579bf57be03add632b0e1624a73576eeda8a1687e0fa286f03eb1a17ffb125ccdb008a264c402f074a360442c7a034e237679322f62268b614e926d10f",
"chainId": "1",
"version": 1
}
response success example:
{
"data": {
"txHash": "6c41c71946b5b428c2cfb560e3ea425f8a00345de4bb2eb1b784387790914277"
},
"error": "",
"code": "successful"
}
response code:400 example:
{
"data": null,
"error": "transaction generation failed: ed25519: invalid signature",
"code": "bad_request"
}
我們可以看到提交的內容有
我們可以建立交易的內容然後送出到full node節點,節點就會幫我們廣播出去等候驗證打包了,明天就來實作這一段。