MAPO Developer Docs
  • MAPO Developer Docs
  • Base
    • MAPO Introduction
    • MAPO token
    • Omnichain DAPP
    • Differences Between Omnichain Applications and Single or Multi-Chain Applications
    • Differences Between Third-Party Trusted Cross-Chain and Peer-to-Peer Cross-Chain Solutions
    • BTC layer2
      • brc-201
    • Oracle
      • Supra: Decentralized Oracle on MAP Protocol
    • Account
    • Transactions
    • block
    • MPT tree
    • RLP
    • Gas fee
    • Cross Chain Message
    • light client
      • MAPO light client
    • MOS
      • MOS interface and functions
      • deploy MOS
      • Messenger
    • map-relay-chain(atlas)
      • atlas architecture
        • atlas architecture
        • atlas genesis
          • genesis config
          • genesis contract
            • ABI
              • Accounts
              • Election
              • EpochRewards
              • LockedGold
              • Validators
            • address
            • deploy
        • precompile-contract
        • protocol
          • Proof of Stake
          • consensus
          • election
          • rewards
          • governance
      • deploy atlas
        • run atlas
        • run atlas(archive)
        • run atlas(bootnodes)
        • run atlas(validator)
        • run atlas(RPC)
      • Marker tool
        • Genesis
        • Validator
        • Vote
        • Common
      • make private network(atlas)
      • public service
        • public network
      • example
        • how-to-vote
        • how-to-withdraw
        • how-to-become-a-new-validator
        • how-to-become-a-new-validator(advanced)
    • Compass(maintainer,messenger)
      • Compass - arch and model
      • Compass - config
      • Compass - deploy
      • Compass secondary development - define your own routing service based on compass
  • MAPO Stack
    • stack
      • Connected Chains and Corresponding Addresses
    • Compatible-EVM
      • Smart Contracts Language
      • Smart Contracts Anatomy
      • Smart Contracts Libraries
      • Smart Contracts Compile
      • Smart Contracts Testing
      • Smart Contracts Deploy
      • Smart Contracts Composability
      • Smart Contracts Security
      • Formal-Verification
      • Frameworks
      • dev-network
    • MAPO Implement Cross-chain Interoperability
      • integration of MAP with EVM-Compatible Chains
        • light client verify
        • light client update state
        • MOS
      • integration of MAP with TON Network
      • integration of MAP with Non-EVM-Compatible Chains
        • light client verify
        • light client update state
        • MOS
    • How to develop cross-chain applications
    • light client address
    • SDK/API
      • MOS interface
      • Light client interface
      • Atlas RPC
        • json-rpc
          • atlas json rpc
          • atlas consensus rpc
        • javaScript sdk
        • go-sdk
      • Backend API
        • SCAN API
  • Zero-Knowledge Proof
    • zk proof
Powered by GitBook
On this page
  • Install
  • Connect to atlas network
  • Atlas network specific features
  1. MAPO Stack
  2. SDK/API
  3. Atlas RPC

go-sdk

atlasclient is forked from ethclient. It inherits most of the functionality of ethclient and adds functionality specific to the Atlas network.

atlasclient is a client for interacting with the Atlas network. It provides a convenient way to connect to the Atlas network, send transactions, interact with smart contracts, and retrieve blockchain data.

Features of atlasclient include:

  1. Connecting to an Atlas network: You can connect to a specific Atlas network, such as the mainnet or a testnet, using the client.

  2. Retrieving blockchain data: You can fetch information about blocks, transactions, and account balances from the Atlas blockchain.

  3. Sending transactions: You can create and send transactions to perform actions on the Atlas network, such as transferring ether or interacting with smart contracts.

  4. Interacting with smart contracts: You can deploy smart contracts, call their functions, and retrieve their state using the client.**

The functions of atlasclient inherited from ethclient are not introduced in this document. We will introduce the unique functions of atlasclient in detail.

Install

go get github.com/mapprotocol/atlasclient

Connect to atlas network

package main

import (
	"context"
	"fmt"

	"github.com/mapprotocol/atlasclient"
)

func main() {
	// connect to atlas network
	cli, err := atlasclient.Dial("https://rpc.maplabs.io")
	if err != nil {
		panic(err)
	}

	// get block info at a specified height
	block, err := cli.MAPBlockByNumber(context.Background(), big.NewInt(15960))
	if err != nil {
		panic(err)
	}
	fmt.Printf("block: %+v\n", block)
}

Atlas network specific features

MAPBlockByHash

Obtain block information through block hash.

package main

import (
	"context"
	"fmt"

	"github.com/mapprotocol/atlasclient"
)

func main() {
	// connect to atlas network
	cli, err := atlasclient.Dial("https://rpc.maplabs.io")
	if err != nil {
		panic(err)
	}

	block, err := cli.MAPBlockByHash(context.Background(), common.HexToHash("0xd30335352288aea176c33162d50f202017b3f5e745d81cdca343fa4b9b1ac93c"))
	if err != nil {
		panic(err)
	}
	fmt.Printf("block: %+v\n", block)

}

MAPBlockByNumber

Get the block information through the block height. If number is nil, get the latest block information.

package main

import (
	"context"
	"fmt"

	"github.com/mapprotocol/atlasclient"
)

func main() {
	// connect to atlas network
	cli, err := atlasclient.Dial("https://rpc.maplabs.io")
	if err != nil {
		panic(err)
	}

	block, err := cli.MAPBlockByNumber(context.Background(), big.NewInt(15960))
	if err != nil {
		panic(err)
	}
	fmt.Printf("block: %+v\n", block)
}

MAPHeaderByNumber

Get the block header information through the block height. If number is nil, get the latest block header information.

package main

import (
	"context"
	"fmt"

	"github.com/mapprotocol/atlasclient"
)

func main() {
	// connect to atlas network
	cli, err := atlasclient.Dial("https://rpc.maplabs.io")
	if err != nil {
		panic(err)
	}

	header, err := cli.MAPHeaderByNumber(context.Background(), big.NewInt(1))
	if err != nil {
		panic(err)
	}
	fmt.Printf("header: %+v\n", header)
}

GetSnapshot

Get the snapshot information of the specified block height. If number is nil, get the latest snapshot information.

package main

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

	"github.com/mapprotocol/atlasclient"
)

func main() {
	// connect to atlas network
	cli, err := atlasclient.Dial("https://rpc.maplabs.io")
	if err != nil {
		panic(err)
	}

	snapshot, err := cli.GetSnapshot(context.Background(), big.NewInt(0))
	if err != nil {
		panic(err)
	}
	fmt.Printf("snapshot: %+v\n", snapshot)
}
PreviousjavaScript sdkNextBackend API

Last updated 1 year ago