tempo-go

module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: Apache-2.0, MIT

README



tempo combomark



tempo-go

Go SDK for building applications on Tempo

Contents

Installation

go get github.com/tempoxyz/tempo-go
Go Version Requirements
tempo-go version Go version Notes
v0.2.0+ 1.24+ Security fix for CVE-2026-22868
v0.1.0 1.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 Case Example
Basic Transfer examples/simple-send
Fee Sponsorship examples/feepayer
Batch Calls See 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)
Sponsored Transaction
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

Package Description Documentation
transaction TempoTransaction encoding, signing, and validation GoDoc
client RPC client for interacting with Tempo nodes GoDoc
signer Key management and signature generation GoDoc
keychain Keychain-based transaction signing GoDoc

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

# 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.

Directories

Path Synopsis
Package examples provides examples for the Tempo Go SDK.
Package examples provides examples for the Tempo Go SDK.
parallel-nonces command
Command parallel-nonces demonstrates how to send multiple transactions in parallel using Tempo's 2D nonce system with different nonce keys.
Command parallel-nonces demonstrates how to send multiple transactions in parallel using Tempo's 2D nonce system with different nonce keys.
simple-send command
Command simple-send demonstrates how to create, sign, and broadcast a Tempo Transaction.
Command simple-send demonstrates how to create, sign, and broadcast a Tempo Transaction.
pkg
client
Package client provides an HTTP RPC client for interacting with the Tempo blockchain.
Package client provides an HTTP RPC client for interacting with the Tempo blockchain.
keychain
Package keychain provides access key management and signing for Tempo transactions.
Package keychain provides access key management and signing for Tempo transactions.
signer
Package signer provides ECDSA signing utilities for Tempo transactions.
Package signer provides ECDSA signing utilities for Tempo transactions.
transaction
Package transaction provides types and functions for working with Tempo Transactions.
Package transaction provides types and functions for working with Tempo Transactions.

Jump to

Keyboard shortcuts

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