tempo-go

June 4, 2026 ยท View on GitHub



Tempo wordmark



tempo-go

Go SDK for building applications on Tempo

Contents

Installation

go get github.com/tempoxyz/tempo-go

Go Version Requirements

tempo-go versionGo versionNotes
v0.2.0+1.24+Security fix for CVE-2026-22868
v0.1.01.21+Vulnerable to CVE-2026-22868 (go-ethereum DoS)

If you need Go 1.21-1.23 support, pin to v0.1.0:

go get github.com/tempoxyz/tempo-go@v0.1.0

Quick Start

package main

import (
    "context"
    "fmt"
    "math/big"

    "github.com/ethereum/go-ethereum/common"
    "github.com/tempoxyz/tempo-go/pkg/client"
    "github.com/tempoxyz/tempo-go/pkg/signer"
    "github.com/tempoxyz/tempo-go/pkg/transaction"
)

func main() {
    // Create RPC client
    c := client.New(transaction.RpcUrlModerato)

    s, _ := signer.NewSigner("0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80")

    recipient := common.HexToAddress("0x70997970C51812dc3A010C7d01b50e0d17dc79C8")
    amount := new(big.Int).Mul(big.NewInt(10), big.NewInt(1e18)) // 10 AlphaUSD (18 decimals)
    transferData := buildERC20TransferData(recipient, amount)

    tx := transaction.NewDefault(transaction.ChainIdModerato)
    tx.MaxFeePerGas = big.NewInt(2000000000)
    tx.MaxPriorityFeePerGas = big.NewInt(1000000000)
    tx.Gas = 100000
    tx.Calls = []transaction.Call{{
        To:    &transaction.AlphaUSDAddress,
        Value: big.NewInt(0),
        Data:  transferData,
    }}

    transaction.SignTransaction(tx, s)

    serialized, _ := transaction.Serialize(tx, nil)
    hash, _ := c.SendRawTransaction(context.Background(), serialized)
    fmt.Printf("Transaction hash: %s\n", hash)
}

// buildERC20TransferData creates calldata for ERC20 transfer(address,uint256)
func buildERC20TransferData(to common.Address, amount *big.Int) []byte {
    // transfer(address,uint256) selector: 0xa9059cbb
    data := make([]byte, 68)
    data[0], data[1], data[2], data[3] = 0xa9, 0x05, 0x9c, 0xbb
    copy(data[16:36], to.Bytes())              // address (32 bytes, left-padded)
    amount.FillBytes(data[36:68])              // uint256 (32 bytes)
    return data
}

Example Usage

Use CaseExample
Basic Transferexamples/simple-send
Fee Sponsorshipexamples/feepayer
Batch CallsSee transaction tests

Basic Transfer

tx := transaction.NewDefault(transaction.ChainIdMainnet)
tx.MaxFeePerGas = big.NewInt(2000000000)
tx.MaxPriorityFeePerGas = big.NewInt(1000000000)
tx.Gas = 100000
tx.Calls = []transaction.Call{{
    To:    &transaction.AlphaUSDAddress,
    Value: big.NewInt(0),
    Data:  transferData, // ERC20 transfer calldata
}}

transaction.SignTransaction(tx, signer)

serialized, _ := transaction.Serialize(tx, nil)
client.SendRawTransaction(context.Background(), serialized)
tx := transaction.NewDefault(transaction.ChainIdMainnet)
transaction.SignTransaction(tx, userSigner)

transaction.AddFeePayerSignature(tx, feePayerSigner)

serialized, _ := transaction.Serialize(tx, nil)
client.SendRawTransaction(context.Background(), serialized)

Batch Multiple Calls

tx := transaction.NewDefault(transaction.ChainIdMainnet)
tx.Gas = 150000
tx.Calls = []transaction.Call{
    {To: &addr1, Value: big.NewInt(0), Data: transfer1Data},
    {To: &addr2, Value: big.NewInt(0), Data: transfer2Data},
    {To: &addr3, Value: big.NewInt(0), Data: contractCallData},
}

transaction.SignTransaction(tx, signer)
serialized, _ := transaction.Serialize(tx, nil)
client.SendRawTransaction(context.Background(), serialized)

Transaction with Validity Window

tx := transaction.NewDefault(transaction.ChainIdMainnet)
tx.ValidAfter = uint64(time.Now().Unix())
tx.ValidBefore = uint64(time.Now().Add(1 * time.Hour).Unix())

transaction.SignTransaction(tx, signer)
serialized, _ := transaction.Serialize(tx, nil)
client.SendRawTransaction(context.Background(), serialized)

Packages

PackageDescriptionDocumentation
transactionTempoTransaction encoding, signing, and validationGoDoc
clientRPC client for interacting with Tempo nodesGoDoc
signerKey management and signature generationGoDoc
keychainKeychain-based transaction signing and witness APIsGoDoc

Testing

Run Unit Tests

make test

Run Tests with Coverage

make test-coverage

Run All Checks (format, vet, tests)

make check

Run Integration Tests

# Start local Tempo node
docker-compose up -d

# Run integration tests
make integration

# Run T5 witness integration tests against a T5-capable RPC
TEMPO_HARDFORK=T5 TEMPO_RPC_URL=<url> make integration

# Stop node
docker-compose down

External Resources

API Reference

View documentation locally:

make docs
# Opens at http://localhost:6060/pkg/github.com/tempoxyz/tempo-go/

Full API documentation is also available on pkg.go.dev.

Development Setup

Prerequisites

Building

git clone https://github.com/tempoxyz/tempo-go.git
cd tempo-go

go mod download

make check

Running Examples

# Build all examples
make build_examples

# Run the simple-send example
./bin/simple-send

# Run the fee payer server
./bin/feepayer

Code Formatting

make fix

Contributing

Our contributor guidelines can be found in CONTRIBUTING.md.

Security

See SECURITY.md. Note: Tempo is still undergoing audit and does not have an active bug bounty. Submissions will not be eligible for a bounty until audits have concluded.

License

Licensed under either of Apache License, Version 2.0 or MIT License at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in these packages by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.