merkle-sdk-go

module
v0.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2023 License: MIT

README

Merkle is building crypto infrastructure. Join us on discord.

Merkle SDK

The Merkle SDK is a great way to access our products.

Install

Install the Merkle SDK package:

go get github.com/merkle3/merkle-sdk-go

Authentication

Get an API key from Merkle Blockchain Services (MBS).

package main

import (
    "github.com/merkle3/merkle-sdk-go/merkle"
)

func main() {
    merkleSdk := merkle.New()

    merkleSdk.SetApiKey("sk_mbs_......") // get one at mbs.https://mbs.merkle.io
}

Features

Stream transactions

Access Merkle's private stream of transactions on Ethereum & Polygon. Learn more

package main

import (
    "github.com/merkle3/merkle-sdk-go/merkle"
)

func main() {
    merkleSdk := merkle.New()

    merkleSdk.SetApiKey("sk_mbs_......") // get one at mbs.https://mbs.merkle.io

    txs, err := merkleSdk.Transactions().Stream(merkle.EthereumMainnet) // pass a chain id, e.g. merkle.EthereumMainnet, merkle.PolygonMainnet or merkle.BnbMainnet

    for {
        select {
            case e := <-err:
			    // error happened
			    fmt.Printf("error: %v\n", e)
            case tx := <-txs:
                // process the transaction
                fmt.Printf("hash: %v\n", tx.Hash().String())
        }
    }
}
Stream auctions

Stream auctions from the Merkle Private Pool. Learn more.

package main

import (
    "github.com/merkle3/merkle-sdk-go/merkle"
)

func main() {
    merkleSdk := merkle.New()

    merkleSdk.SetApiKey("sk_mbs_......") // get one at mbs.merkle.io

    auctions, err := merkleSdk.Pool().Auctions()

    for {
        select {
            case e := <-err:
            // error happened
            case auction := <-auctions:
            // process the auction, create a backrun

            // then send the bid
            err := auction.SendBid(tx) // a signed types.Transaction

            // or send a raw bid
            err := auction.SendRawBid([]string{
                // hex encoded bid
                "0x...."
            })

            // check for error in case the auction is already closed
        }
    }
}

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL