Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
feat(BUX-156): add batch example
Browse files Browse the repository at this point in the history
  • Loading branch information
arkadiuszos4chain committed Aug 8, 2023
1 parent c396e56 commit 2526c96
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions examples/submit_batch_transactions/submit_batch_txs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package main

import (
"context"
"log"

"github.com/bitcoin-sv/go-broadcast-client/broadcast"
broadcast_client "github.com/bitcoin-sv/go-broadcast-client/broadcast/broadcast-client"
)

func main() {
token := "{token}"
apiURL := "https://tapi.taal.com/arc"
txs := []*broadcast.Transaction{
{RawTx: "0100000001d6d1607b208b30c0a3fe21d563569c4d2a0f913604b4c5054fe267da6be324ab220000006b4830450221009a965dcd5d42983090a63cfd761038ff8adcea621c46a68a205f326292a95383022061b8d858f366c69f3ebd30a60ccafe36faca4e242ac3d2edd3bf63b669bcf23b4121034e871e147aa4a3e2f1665eaf76cf9264d089b6a91702af92bd6ce33bac84a765ffffffff0123020000000000001976a914d8819a7197d3e221e15f4348203fdecfd29fa2b888ac00000000"},
{RawTx: "0100000001bbf4d68a935126df1eea3e14714c5a6438bbda3d18b7e754bc90895cf2190196060000006a47304402206a0c3923a9ae253ac5ea22d36e667f067c51f88a8bfb2861d9124bc5402fecd00220745731fa951076c63df2de6528616e0ef97ef8ade5b17d8e1d51494cf153a64b412103af3ead8a3ab792225bf22262f0b81a72e5070788d363ee717c5868421b75a62dffffffff01000000000000000040006a0a6d793263656e74732c201c4759384d656c46634d326449674d75557356644d53776f6a66467431152c20302e323135353133313536343634343531313600000000"},
{RawTx: "0100000001bbf4d68a935126df1eea3e14714c5a6438bbda3d18b7e754bc90895cf21901962b0000006a47304402202eb4a5a437da4f2d17f0301e8f7fe1364a3655069797284501b5295d707238e802202ff312652a492ff9bd63c700283abe321b637b34b41794e47b37d589503132c1412103af3ead8a3ab792225bf22262f0b81a72e5070788d363ee717c5868421b75a62dffffffff01000000000000000042006a0a6d793263656e74732c201c625a753465447130333856726a75736e6f4651746573455355344c32172c20302e3030313834343339383431333331333235393800000000"},
{RawTx: "010000000141dcf2f3e9146db096eaab29576546567c81ec43b181f61012606d0bd6e2ad5c010000006b483045022100bda2f44e5c27f1c10ca908996125d4debbc8bfdd9e23c8140d3006390d71ffd50220486c0725a03e798295270b20b1163f525f211a4be4cd9855225e4a3865ab3ae841210262142850483b6728b8ecd299e4d0c8cf30ea0636f66205166814e52d73b64b4bffffffff0200000000000000000a006a075354554b2e434f8ea2e60c000000001976a91454cba8da8701174e34aac2bb31d42a88e2c302d088ac00000000"},
{RawTx: "01000000018e5cbbfdf1c4e1c168037bbb305be7018de2d19f6de919c75678daad07c375af010000006b483045022100a0b73eca88a56b30e7f2ea7388aac64506cbdccdc04452b9150344054fc969ae022071dc9e99e42825495ab4f274066a519f0ecaf671d84c156b37458fcd888159ba41210262142850483b6728b8ecd299e4d0c8cf30ea0636f66205166814e52d73b64b4bffffffff0200000000000000000a006a075354554b2e434f90a2e60c000000001976a91454cba8da8701174e34aac2bb31d42a88e2c302d088ac00000000"},
}

cfg := broadcast_client.ArcClientConfig{
Token: token,
APIUrl: apiURL,
}

client := broadcast_client.Builder().
WithArc(cfg).
Build()

result, err := client.SubmitBatchTransactions(context.Background(), txs)
if err != nil {
log.Fatalf("error: %s", err.Error())
}

for i, tx := range result {
log.Printf("tx[%d]: { hash: %s, status: %s }", i, tx.BlockHash, tx.TxStatus)
}

}

0 comments on commit 2526c96

Please sign in to comment.