Skip to main content

Go integration

Use Go for backend tools, self-hosted protocol services and applications with explicit signing capabilities. The example requires Go 1.26.1 or newer and matching SDK modules. Check compatibility and available module tags before installation.

Modules​

Applications normally import github.com/invisi-labs/invisi-sdk-go/sdk. Separate primitives, protocol, prover, rpc, session and ipp modules provide optional capabilities. Use compatible versions for interacting modules. Address or public DTO handling does not require a prover or session.

Offline output​

This complete Go program constructs a Note output using only public receiving material and performs no network requests. Configure compatible SDK and go-ethereum dependencies, save it as main.go, and run go run .. The example chain and contract addresses are offline bindings, not deployed instances.

package main

import (
"fmt"
"log"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/invisi-labs/invisi-sdk-go/sdk"
)

func main() {
output, err := sdk.NewNoteOutput(sdk.PaymentRequest{
ChainID: big.NewInt(31337),
ProtocolAddress: common.HexToAddress("0x1111111111111111111111111111111111111111"),
TokenAddress: common.HexToAddress("0x2222222222222222222222222222222222222222"),
Amount: big.NewInt(10),
Recipient: sdk.InvisiRecipient{Address: "0i0e0525SFRf53yh2aljmm3sn9JQ5nJk7LqWt0G2ajnRY2pe698y550QXhp9uELXpcCZMf5Y608rRDJ68jJgfEWy5j7U5e5eVNPVz8vW2W2kmyw4p9lVLwW3z3WeFHQs5KdfR980CX"},
})
if err != nil { log.Fatal(err) }
fmt.Println(output.Commitment())
}

big.NewInt(10) means ten base units. Commitment() does not establish received funds, and randomization can change its value on each run.

Payment integration​

  1. Construct a public Wallet with sdk.WalletFromAddress.
  2. Inject the chain provider, Protocol RPC and local prover; confirm the instance.
  3. Supply explicit inputs for stateless operations, or use session.Connect with persistent storage for managed inventory.
  4. Prepare using PrepareShield or PrepareTransfer. For private authorization, export typed data through ExportWalletAuthorization, sign in the application and attach with WithWalletSignature.
  5. Use Ready(ctx) for Shield. For private operations requiring ZK evidence, use Prove(ctx) before exporting calldata. Credit revocation follows its separate owner-authorization path without proving. Submit through the host’s geth signing and sending flow.
  6. Retain the operation ID and transaction hash, then reconcile verified receipts. Recover the original operation on timeout.

Provide authenticated DeliveryDecryptor callbacks. Only a known nonrecipient returns nil, nil; locking, cancellation and authentication failures are errors. The owner-bound sweep boundary also applies in Go.

Credit has distinct state and operations, not an ordinary Note balance. Read Credit and recovery for shared cross-language semantics.

Download the complete offline example