Skip to main content

API Reference

Overview

The Atlas SDK provides a comprehensive set of methods to interact with the Atlas smart contracts deployed on various Ethereum-compatible blockchain networks. It facilitates operations such as simulating user and solver actions, managing nonces, sorting solver operations, and executing meta-calls. This documentation outlines the available methods, their parameters, return types, and descriptions to help developers effectively utilize the SDK in their applications.

AtlasSdk

New

Initializes a new instance of the Atlas SDK with the provided Ethereum clients and chain configurations.

Parameters

NameTypeDescription
rpcClients[]interfaceA slice of Ethereum or RPC clients connected to different blockchain networks.
chainOverridesmap[uint64]map[string]*config.ChainConfigA map containing chain IDs as keys and their corresponding chain configurations to override defaults.

Returns

TypeDescription
*AtlasSdkThe initialized Atlas SDK instance.
errorAn error object if the initialization fails.

Example

ethClient, _ := ethclient.Dial("https://rpc.sepolia.org")
defer ethClient.Close()

sdk, err := core.NewAtlasSdk([]interface{}{ethClient}, nil)

Metacall

Calls the Atlas metacall function.

Parameters

NameTypeDescription
chainIduint64The targeted chain ID.
version*stringThe targeted Atlas version (set nil for latest).
transactOpts*bind.TransactOptsThe required data to submit the transaction.
userOp*types.UserOperationThe user operation.
solverOpstypes.SolverOperationsThe solver operations.
dAppOp*types.DAppOperationThe dApp operation.
gasRefundBeneficiary*common.AddressThe gas refund beneficiary (set nil for default value).

Returns

TypeDescription
*types.TransactionThe generated and submitted transaction.
errorAn error object if the call has failed.

GetBalanceOfBondedAtlEth

Retrieves an account bonded atlEth balance for a particular chain ID / Atlas version.

Parameters

NameTypeDescription
chainIduint64The targeted chain ID.
version*stringThe targeted Atlas version (set nil for latest).
accountcommon.AddressThe account to get the balance for.

Returns

TypeDescription
*big.IntThe bonded atlEth balance for the account.
errorAn error object if the call has failed.

Example

account := common.HexToAddress("0x1234567890123456789012345678901234567890")
atlEthBondedBalance, err := sdk.GetBalanceOfBondedAtlEth(11155111, nil, account)

GetDAppCallConfig

Retrieves a dApp control's call config.

Parameters

NameTypeDescription
chainIduint64The targeted chain ID.
dAppControlAddrcommon.AddressThe dApp control's address.

Returns

TypeDescription
uint32The call config value.
errorAn error object if the call has failed.

Example

dAppControlAddress := common.HexToAddress("0x1234567890123456789012345678901234567890")
callConfig, err := sdk.GetDAppCallConfig(11155111, dAppControlAddress)

GetDAppConfig

Retrieves a dApp control's full config.

Parameters

NameTypeDescription
chainIduint64The targeted chain ID.
userOp*types.UserOperationA user operation.
dAppControlAddrcommon.AddressThe dApp control's address.

Returns

TypeDescription
*dappcontrol.DAppConfigThe full dApp config object.
errorAn error object if the call has failed.

Example

userOperation := &types.UserOperation{}
dAppControlAddress := common.HexToAddress("0x1234567890123456789012345678901234567890")
dAppConfig, err := sdk.GetDAppCallConfig(11155111, userOperation, dAppControlAddress)

GetDAppSolverGasLimit

Retrieves the solver gas limit for a particular dApp control.

Parameters

NameTypeDescription
chainIduint64The targeted chain ID.
dAppControlAddrcommon.AddressThe dApp control's address.

Returns

TypeDescription
*big.IntThe solver gas limit for this dApp control.
errorAn error object if the call has failed.

Example

dAppControlAddress := common.HexToAddress("0x1234567890123456789012345678901234567890")
solverGasLimit, err := sdk.GetDAppSolverGasLimit(11155111, dAppControlAddress)

SetUserNonce

Sets the next valid user nonce on the passed user operation.

Parameters

NameTypeDescription
chainIduint64The targeted chain ID.
version*stringThe targeted Atlas version (set nil for latest).
userOp*types.UserOperationThe user operation to set the nonce for.

Returns

TypeDescription
errorAn error object if the call has failed.

Example

userOperation := &types.UserOperation{}
err := sdk.SetUserNonce(11155111, nil, userOperation)

GetUserNextNonce

Retrieves the next valid user nonce on the passed user operation.

Parameters

NameTypeDescription
chainIduint64The targeted chain ID.
version*stringThe targeted Atlas version (set nil for latest).
userOp*types.UserOperationThe user operation to set the nonce for.
callConfiguint32The call config for the dApp control.

Returns

TypeDescription
*big.IntThe next valid nonce for this user operation.
errorAn error object if the call has failed.

Example

userOperation := &types.UserOperation{}
dAppControlAddress := common.HexToAddress("0x1234567890123456789012345678901234567890")
callConfig, _ := sdk.GetDAppCallConfig(11155111, dAppControlAddress)
nextNonce, err := sdk.GetUserNextNonce(11155111, nil, userOperation, callConfig)

GetDAppNextNonce

Retrieves the next valid dApp nonce on the passed dApp control.

Parameters

NameTypeDescription
chainIduint64The targeted chain ID.
version*stringThe targeted Atlas version (set nil for latest).
dAppcommon.AddressThe address of the dApp control.
callConfiguint32The call config for the dApp control.

Returns

TypeDescription
*big.IntThe next valid nonce for this dApp control.
errorAn error object if the call has failed.

Example

dAppControlAddress := common.HexToAddress("0x1234567890123456789012345678901234567890")
callConfig, _ := sdk.GetDAppCallConfig(11155111, dAppControlAddress)
nextNonce, err := sdk.GetDAppNextNonce(11155111, nil, dAppControlAddress, callConfig)

SimulateUserOperation

Simulates a user operation using the Atlas simulator.

Parameters

NameTypeDescription
chainIduint64The targeted chain ID.
version*stringThe targeted Atlas version (set nil for latest).
userOp*types.UserOperationThe user operation to simulate.

Returns

TypeDescription
*UserOperationSimulationErrorThe details of the failure, or nil if the simulation passed.

Example

userOperation := &types.UserOperation{}
simulationErr := sdk.SimulateUserOperation(11155111, nil, userOperation)

SimulateSolverOperation

Simulates a solver operation using the Atlas simulator.

Parameters

NameTypeDescription
chainIduint64The targeted chain ID.
version*stringThe targeted Atlas version (set nil for latest).
userOp*types.UserOperationThe user operation to simulate.
solverOp*types.SolverOperationThe solver operation to simulate.
allowTracingbooleanAllow call tracing when simulating. This is only relevant for dApp controls that enable exPostBids.

Returns

TypeDescription
*big.IntThe solver bid amount
*SolverOperationSimulationErrorThe details of the failure, or nil if the simulation passed.

Example

userOperation := &types.UserOperation{}
solverOperation := &types.SolverOperation{}
solverBidAmount, simulationErr := sdk.SimulateSolverOperation(11155111, nil, userOperation, solverOperation, false)

SortSolverOperations

Sorts solver operations according to the dApp control rules.

Parameters

NameTypeDescription
chainIduint64The targeted chain ID.
version*stringThe targeted Atlas version (set nil for latest).
userOp*types.UserOperationThe user operation.
solverOp*types.SolverOperationThe solver operation to sort.

Returns

TypeDescription
types.SolverOperationsThe sorted solver operations.
errorAn error object if the call has failed.
warning

The returned slice could be empty, if none of the submitted solver operations passed minimal validation.

Example

userOperation := &types.UserOperation{}
solverOperation1 := &types.SolverOperation{}
solverOperation2 := &types.SolverOperation{}
sortedSolverOperations, err := sdk.SortSolverOperations(11155111, nil, userOperation, []*types.SolverOperation{solverOperation1, solverOperation2})

UserOperation

type UserOperation struct {
From common.Address
To common.Address
Value *big.Int
Gas *big.Int
MaxFeePerGas *big.Int
Nonce *big.Int
Deadline *big.Int
Dapp common.Address
Control common.Address
CallConfig uint32
SessionKey common.Address
Data []byte
Signature []byte
}

EncodeToRaw

Returns the serialized version of the user operation.

Parameters

No parameters.

Returns

TypeDescription
*types.UserOperationRawThe serialized user operation.

Example

userOperation := &types.UserOperation{}
serializedUserOperation := userOperation.EncodeToRaw()

Hash

Computes the canonical hash for an Atlas user operation. Note a user operation hash is dependant on chain ID and Atlas version.

Parameters

NameTypeDescription
trustedbooleanShould the hash be trusted.
chainIduint64The targeted chain ID.
version*stringThe targeted Atlas version (set nil for latest).

Returns

TypeDescription
common.HashThe hash of the user operation.
errorAn error object if the call has failed.

Example

userOperation := &types.UserOperation{}
hash, err := userOperation.Hash(true, 11155111, nil)

AbiEncode

Gets the user operation abi encoded.

Parameters

No parameters.

Returns

TypeDescription
[]byteThe user operation abi encoded, as bytes.
errorAn error object if the call has failed.

Example

userOperation := &types.UserOperation{}
uoAbiEncoded, err := userOperation.AbiEncode()

ValidateSignature

Validates the user operation signature.

Parameters

NameTypeDescription
chainIduint64The targeted chain ID.
version*stringThe targeted Atlas version (set nil for latest).

Returns

TypeDescription
errorAn error object if the call has failed, or nil if the signature is valid.

Example

userOperation := &types.UserOperation{}
err := userOperation.ValidateSignature(11155111, nil)

UserOperationRaw

type UserOperationRaw struct {
From common.Address `json:"from"`
To common.Address `json:"to"`
Value *hexutil.Big `json:"value"`
Gas *hexutil.Big `json:"gas"`
MaxFeePerGas *hexutil.Big `json:"maxFeePerGas"`
Nonce *hexutil.Big `json:"nonce"`
Deadline *hexutil.Big `json:"deadline"`
Dapp common.Address `json:"dapp"`
Control common.Address `json:"control"`
CallConfig *hexutil.Big `json:"callConfig"`
SessionKey common.Address `json:"sessionKey"`
Data hexutil.Bytes `json:"data"`
Signature hexutil.Bytes `json:"signature"`
}

Decode

Deserializes the user operation.

Parameters

No parameters.

Returns

TypeDescription
*types.UserOperationThe deserialized user operation.

Example

serializedUserOperation := &types.UserOperationRaw{}
userOperation := serializedUserOperation.Decode()

UserOperationPartialRaw

type UserOperationPartialRaw struct {
ChainId *hexutil.Big `json:"chainId"`

UserOpHash common.Hash `json:"userOpHash"`
To common.Address `json:"to"`
Gas *hexutil.Big `json:"gas"`
MaxFeePerGas *hexutil.Big `json:"maxFeePerGas"`
Deadline *hexutil.Big `json:"deadline"`
Dapp common.Address `json:"dapp"`
Control common.Address `json:"control"`

//Exactly one of 1. Hints 2. (Value, Data, From) must be set
Hints []common.Address `json:"hints,omitempty"`

Value *hexutil.Big `json:"value,omitempty"`
Data hexutil.Bytes `json:"data,omitempty"`
From common.Address `json:"from,omitempty"`
}

New

Creates a new instance.

Parameters

NameTypeDescription
chainIduint64The targeted chain ID.
version*stringThe targeted Atlas version (set nil for latest).
userOp*types.UserOperationThe user operation.
hints[]common.AddressA slice of hints.

Returns

TypeDescription
*types.UserOperationPartialRawThe generated partial user operation, serialized.
errorAn error object if the call has failed.

Example

userOperation := &types.UserOperation{}
partialUserOperationSeralized, err := types.NewUserOperationPartialRaw(11155111, nil, userOperation, []common.Address{})

UserOperationWithHintsRaw

type UserOperationWithHintsRaw struct {
ChainId *hexutil.Big `json:"chainId"`
UserOperation *UserOperationRaw `json:"userOperation"`
Hints []common.Address `json:"hints"`
}

New

Creates a new instance.

Parameters

NameTypeDescription
chainIduint64The targeted chain ID.
userOp*types.UserOperationThe user operation.
hints[]common.AddressA slice of hints.

Returns

TypeDescription
*types.UserOperationWithHintsRawThe generated user operation with hints, serialized.

Example

userOperation := &types.UserOperation{}
userOperationWithHintsSeralized, err := types.NewUserOperationWithHintsRaw(11155111, userOperation, []common.Address{})

Decode

Deserializes the data.

Parameters

No parameters.

Returns

TypeDescription
uint64The chain ID.
*types.UserOperationThe user operation.
[]common.AddressThe slice of hints.

Example

userOperationWithHintsSeralized := &types.UserOperationWithHintsRaw{}
chainId, userOperation, hints := userOperationWithHintsSeralized.Decode()

SolverOperation

type SolverOperation struct {
From common.Address
To common.Address
Value *big.Int
Gas *big.Int
MaxFeePerGas *big.Int
Deadline *big.Int
Solver common.Address
Control common.Address
UserOpHash common.Hash
BidToken common.Address
BidAmount *big.Int
Data []byte
Signature []byte
}

EncodeToRaw

Returns the serialized version of the solver operation.

Parameters

No parameters.

Returns

TypeDescription
*types.SolverOperationRawThe serialized solver operation.

Example

solverOperation := &types.SolverOperation{}
serializedSolverOperation := solverOperation.EncodeToRaw()

Hash

Computes the canonical hash for an Atlas solver operation. Note a solver operation hash is dependant on chain ID and Atlas version.

Parameters

NameTypeDescription
chainIduint64The targeted chain ID.
version*stringThe targeted Atlas version (set nil for latest).

Returns

TypeDescription
common.HashThe hash of the solver operation.
errorAn error object if the call has failed.

Example

solverOperation := &types.SolverOperation{}
hash, err := solverOperation.Hash(11155111, nil)

AbiEncode

Gets the solver operation abi encoded.

Parameters

No parameters.

Returns

TypeDescription
[]byteThe solver operation abi encoded, as bytes.
errorAn error object if the call has failed.

Example

solverOperation := &types.SolverOperation{}
soAbiEncoded, err := solverOperation.AbiEncode()

ValidateSignature

Validates the solver operation signature.

Parameters

NameTypeDescription
chainIduint64The targeted chain ID.
version*stringThe targeted Atlas version (set nil for latest).

Returns

TypeDescription
errorAn error object if the call has failed, or nil if the signature is valid.

Example

solverOperation := &types.SolverOperation{}
err := solverOperation.ValidateSignature(11155111, nil)

SolverOperationRaw

type SolverOperationRaw struct {
From common.Address `json:"from"`
To common.Address `json:"to"`
Value *hexutil.Big `json:"value"`
Gas *hexutil.Big `json:"gas"`
MaxFeePerGas *hexutil.Big `json:"maxFeePerGas"`
Deadline *hexutil.Big `json:"deadline"`
Solver common.Address `json:"solver"`
Control common.Address `json:"control"`
UserOpHash common.Hash `json:"userOpHash"`
BidToken common.Address `json:"bidToken"`
BidAmount *hexutil.Big `json:"bidAmount"`
Data hexutil.Bytes `json:"data"`
Signature hexutil.Bytes `json:"signature"`
}

Decode

Deserializes the solver operation.

Parameters

No parameters.

Returns

TypeDescription
*types.SolverOperationThe deserialized solver operation.

Example

serializedSolverOperation := &types.SolverOperationRaw{}
solverOperation := serializedSolverOperation.Decode()

DAppOperation

type DAppOperation struct {
From common.Address
To common.Address
Nonce *big.Int
Deadline *big.Int
Control common.Address
Bundler common.Address
UserOpHash common.Hash
CallChainHash common.Hash
Signature []byte
}

EncodeToRaw

Returns the serialized version of the dApp operation.

Parameters

No parameters.

Returns

TypeDescription
*types.DAppOperationRawThe serialized dApp operation.

Example

dAppOperation := &types.DAppOperation{}
serializedDAppOperation := dAppOperation.EncodeToRaw()

Hash

Computes the canonical hash for an Atlas dApp operation. Note a dApp operation hash is dependant on chain ID and Atlas version.

Parameters

NameTypeDescription
chainIduint64The targeted chain ID.
version*stringThe targeted Atlas version (set nil for latest).

Returns

TypeDescription
common.HashThe hash of the dApp operation.
errorAn error object if the call has failed.

Example

dAppOperation := &types.DAppOperation{}
hash, err := dAppOperation.Hash(11155111, nil)

ValidateSignature

Validates the dApp operation signature.

Parameters

NameTypeDescription
chainIduint64The targeted chain ID.
version*stringThe targeted Atlas version (set nil for latest).

Returns

TypeDescription
errorAn error object if the call has failed, or nil if the signature is valid.

Example

dAppOperation := &types.DAppOperation{}
err := dAppOperation.ValidateSignature(11155111, nil)

DAppOperationRaw

type DAppOperationRaw struct {
From common.Address `json:"from"`
To common.Address `json:"to"`
Nonce *hexutil.Big `json:"nonce"`
Deadline *hexutil.Big `json:"deadline"`
Control common.Address `json:"control"`
Bundler common.Address `json:"bundler"`
UserOpHash common.Hash `json:"userOpHash"`
CallChainHash common.Hash `json:"callChainHash"`
Signature hexutil.Bytes `json:"signature"`
}

Decode

Deserializes the dApp operation.

Parameters

No parameters.

Returns

TypeDescription
*types.DAppOperationThe deserialized dApp operation.

Example

serializedDAppOperation := &types.DAppOperationRaw{}
dAppOperation := serializedDAppOperation.Decode()

Bundle

type Bundle struct {
ChainId uint64
UserOperation *types.UserOperation
SolverOperations types.SolverOperations
DAppOperation types.*DAppOperation
}

EncodeToRaw

Returns the serialized version of the bundle.

Parameters

No parameters.

Returns

TypeDescription
*types.BundleRawThe serialized bundle.

Example

bundle := &types.Bundle{}
serializedBundle := bundle.EncodeToRaw()

BundleRaw

type BundleRaw struct {
ChainId *hexutil.Big `json:"chainId"`
UserOperation *types.UserOperationRaw `json:"userOperation"`
SolverOperations types.SolverOperationsRaw `json:"solverOperations"`
DAppOperation *types.DAppOperationRaw `json:"dAppOperation"`
}

Decode

Deserializes the bundle.

Parameters

No parameters.

Returns

TypeDescription
*types.BundleThe deserialized bundle.

Example

serializedBundle := &types.BundleRaw{}
bundle := serializedBundle.Decode()

Utils

CallChainHash

Compute the call chain hash of the given operations.

Parameters

NameTypeDescription
userOp*types.UserOperationA user operation.
solverOpstypes.SolverOperationsA slice of solver operations.

Returns

TypeDescription
common.HashThe computed call chain hash.
errorAn error object if the call has failed, or nil if the signature is valid.

Example

import "github.com/FastLane-Labs/atlas-sdk-go/core"

userOperation := &types.UserOperation{}
solverOperation1 := &types.SolverOperation{}
solverOperation2 := &types.SolverOperation{}
callChainHash, err := core.CallChainHash(userOperation, []*types.SolverOperation{solverOperation1, solverOperation2})

CallConfigFlags

Collection of functions returning booleans, indicating if dApp control flags are enabled/disabled, given a dApp call config.

import "github.com/FastLane-Labs/atlas-sdk-go/utils"

var enabled bool
var callConfig uint32

enabled = utils.FlagUserNoncesSequential(callConfig)
enabled = utils.FlagDappNoncesSequential(callConfig)
enabled = utils.FlagRequirePreOps(callConfig)
enabled = utils.FlagTrackPreOpsReturnData(callConfig)
enabled = utils.FlagTrackUserReturnData(callConfig)
enabled = utils.FlagDelegateUser(callConfig)
enabled = utils.FlagRequirePreSolver(callConfig)
enabled = utils.FlagRequirePostSolver(callConfig)
enabled = utils.FlagRequirePostOps(callConfig)
enabled = utils.FlagZeroSolvers(callConfig)
enabled = utils.FlagReuseUserOp(callConfig)
enabled = utils.FlagUserAuctioneer(callConfig)
enabled = utils.FlagSolverAuctioneer(callConfig)
enabled = utils.FlagUnknownAuctioneer(callConfig)
enabled = utils.FlagVerifyCallChainHash(callConfig)
enabled = utils.FlagForwardReturnData(callConfig)
enabled = utils.FlagRequireFulfillment(callConfig)
enabled = utils.FlagTrustedOpHash(callConfig)
enabled = utils.FlagInvertBidValue(callConfig)
enabled = utils.FlagExPostBids(callConfig)
enabled = utils.FlagAllowAllocateValueFailure(callConfig)