OKX Web3 Go Wallet SDK

repository·main·Indexed 20 days ago

https://github.com/okx/go-wallet-sdk

A modular Go SDK for building multi-chain wallet applications. It provides tools for offline transaction signing, account management, and support for various blockchain standards (such as BRC20 on Bitcoin) across multiple public chains, including Aptos, Avalanche, Bitcoin, Cardano, Cosmos, Elrond, and EOS.

Tokens
147.1K
Snippets
702
Records
787
Agent score
69%

What's inside okx-go-wallet-sdk

  1. Important: Offline-only operation requirements

    main

    The Tron SDK is an offline-only library. It does not communicate with the blockchain directly. To successfully sign transactions that can be broadcast, the caller MUST provide the following parameters sourced from a Tron node:

    • RefBlockBytes
    • RefBlockHash
    • Expiration
    • Timestamp
    • FeeLimit (required for TRC-20 transfers)
  2. How the OKX Web3 Go Wallet SDK is architected

    main

    The SDK uses a modular architecture designed for extensibility. It is composed of three core components:

    1. coins: Contains the implementation for transaction creation and signing for each supported blockchain.
    2. crypto: Handles general cryptographic operations and signature algorithms.
    3. util: Provides helper utilities for common operations.

    This modularity allows developers to easily integrate or extend the SDK with new blockchains by following the existing structure in the coins directory.

  3. Understand the licensing for go-ethereum primitives

    main

    The crypto/go-ethereum directory contains a vendored snapshot of go-ethereum used for Ethereum primitives (common types, crypto, RLP, EIP-712 typed-data hashing, transaction types, etc.).

    Most code in this directory is licensed under LGPL-3.0-or-later. However, specific subdirectories use different licenses and are NOT LGPL:

    • crypto/bn256/: See crypto/bn256/LICENSE
    • crypto/ecies/: See crypto/ecies/LICENSE
    • crypto/secp256k1/: See crypto/secp256k1/LICENSE
  4. Simulate TON or Jetton transfers to estimate gas

    main

    To estimate gas charges without actually sending a transaction, set the simulate parameter to true in either Transfer or TransferJetton. When simulating, the seed can be passed as nil in the Transfer function.

    // Example for TON simulation
    simulate := true
    signedTx, err := Transfer(nil, pubKey, to, amount, comment, seqno, expireAt, 3, simulate, wallet.V4R2)
    // signedTx.Tx is used to estimate gas charges
  5. Populate go-ethereum license files

    main

    To ensure the directory contains the canonical license texts from upstream go-ethereum, run the following commands from the repository root. This requires network access to github.com.

    # Requires network access to github.com; run manually.
    curl -fsSL https://raw.githubusercontent.com/ethereum/go-ethereum/master/COPYING \
      -o crypto/go-ethereum/COPYING
    curl -fsSL https://raw.githubusercontent.com/ethereum/go-ethereum/master/COPYING.LESSER \
      -o crypto/go-ethereum/COPYING.LESSER