Constellation Network
IntroductionFundamentalsFor DevelopersNode Validators
  • Index
  • Guide
    • Introduction
    • Provider Activation
    • Sending RPC Requests
    • Signing Data
    • Supported Connectors
    • Using External Libraries
  • API Reference
    • Overview
    • Wallet provider API
      • Overview
      • errorTypes
      • version
      • getProvider()
  • Chain Provider API
    • Overview
    • activated
    • chain
    • version
    • on()
    • removeListener()
    • async activate()
    • async onAsync()
    • async removeListenerAsync()
    • async request()
  • Constellation RPC API
    • Overview
    • dag_accounts
    • dag_chainId
    • dag_getBalance
    • dag_getMetagraphBalance
    • dag_getMetagraphPendingTransaction
    • dag_getMetagraphTransaction
    • dag_getPendingTransaction
    • dag_getPublicKey
    • dag_getTransaction
    • dag_requestAccounts
    • dag_sendMetagraphTransaction
    • dag_sendMetagraphDataTransaction
    • dag_signMetagraphDataTransaction
    • dag_sendTransaction
    • dag_signData
    • dag_signMessage
    • wallet_watchAsset
    • dag_delegatedStake
    • dag_withdrawDelegatedStake
    • dag_allowSpend
    • dag_tokenLock
  • Ethereum RPC API
    • Overview
    • eth_accounts
    • eth_blockNumber
    • eth_call
    • eth_chainId
    • eth_estimateGas
    • eth_gasPrice
    • eth_getBalance
    • eth_getBlockByHash
    • eth_getBlockByNumber
    • eth_getBlockTransactionCountByHash
    • eth_getBlockTransactionCountByNumber
    • eth_getCode
    • eth_getFilterChanges
    • eth_getFilterLogs
    • eth_getLogs
    • eth_getStorageAt
    • eth_getTransactionByBlockHashAndIndex
    • eth_getTransactionByBlockNumberAndIndex
    • eth_getTransactionByHash
    • eth_getTransactionCount
    • eth_getTransactionReceipt
    • eth_getUncleByBlockHashAndIndex
    • eth_getUncleByBlockNumberAndIndex
    • eth_getUncleCountByBlockHash
    • eth_getUncleCountByBlockNumber
    • eth_newBlockFilter
    • eth_newFilter
    • eth_protocolVersion
    • eth_requestAccounts
    • eth_sendTransaction
    • eth_signTypedData
    • eth_signTypedData_v4
    • eth_uninstallFilter
    • net_version
    • personal_sign
    • web3_sha3
  • Resources
    • Stargazer Github
    • Stargazer Connector Github
    • Stargazer Demos Github
    • Stargazer Chrome
    • Stargazer Android
    • Stargazer IOS
    • EIP-1193
Powered by GitBook

Main

  • Website
  • Get DAG
  • Explore Projects
  • Partners

Socials

  • Telegram
  • Discord
  • X (Twitter)

Tools

  • Wallet
  • DAG Explorer
  • Coingecko

© 2025 CONSTELLATION NETWORK

On this page
  • List active account​
  • Send an ETH contract call​
  • Send ETH Transactions​

Was this helpful?

Export as PDF
  1. Guide

Sending RPC Requests

PreviousProvider ActivationNextSigning Data

Last updated 2 months ago

Was this helpful?

Communication with the wallet is sent via RPC requests. This guide will show you how to send an RPC request and how to interpret responses.

Obtain a chain provider

With the steps mentioned in , get a chain provider for the networks you want to interact with. In the following examples we will use both ethereum and constellation providers.

const dagProvider = window.stargazer.getProvider("constellation");
const ethProvider = window.stargazer.getProvider("ethereum");

List active account

For listing the active accounts in the wallet you can send the following calls to RPC method and RPC method.

Important

The account returned will always be the active account in Stargazer. Both for Constellation and Ethereum providers.

const dagAccounts = await dagProvider.request({ method: "dag_accounts" });
console.log(dagAccounts);
// ["DAG88C9WDSKH451sisyEP3hAkgCKn5DN72fuwjfX"]

const ethAccounts = await ethProvider.request({ method: "eth_accounts" });
console.log(eth_accounts);
// ["0x567d0382442c5178105fC03bd52b8Db6Afb4fE40"]

Read more about and .

Send an ETH contract call

Important

You can think about an ABI as any other programming interface, where you have defined method signatures and interaction abstractions without the actual implementation.

import * as ethers from "ethers";

const ethersProvider = new ethers.providers.Web3Provider(ethProvider);

const StargazerGreeterAddress = "0x74299a718b2c44483a27325d7725f0b2646de3b1";
const StargazerGreeterABI = [...[]]; // You can get StargazerGreeter's ABI from https://sepolia.etherscan.io/address/0x74299a718b2c44483a27325d7725f0b2646de3b1#code;

const contract = new ethers.Contract(
  StargazerGreeterAddress,
  StargazerGreeterABI,
  ethersProvider
);

await contract.greet();
// "Bon Matin!"

Important

import * as ethers from "ethers";

const ethersProvider = new ethers.providers.Web3Provider(ethProvider);

const signer = ethersProvider.getSigner();

const StargazerGreeterAddress = "0x74299a718b2c44483a27325d7725f0b2646de3b1";
const StargazerGreeterABI = [...[]]; // You can get StargazerGreeter's ABI from https://sepolia.etherscan.io/address/0x74299a718b2c44483a27325d7725f0b2646de3b1#code;

const contract = new ethers.Contract(
  StargazerGreeterAddress,
  StargazerGreeterABI,
  signer
);

const greetingId = 1; // Bon Matin!

// We send a transaction to the network
const trxResponse = await contract.setGreeting(greetingId);

// We wait for confirmation
const trxReceipt = await library.waitForTransaction(trxResponse.hash);

console.log(trxReceipt.blockNumber);
// 12415408
import * as ethers from "ethers";

const ethersProvider = new ethers.providers.Web3Provider(ethProvider);

const signer = ethersProvider.getSigner();

const StargazerSampleTokenAddress =
  "0xfe9885baff18074846aaa2d5541581adf068731d";
const StargazerSampleTokenABI = [...[]]; // You can get StargazerSampleToken's ABI from https://sepolia.etherscan.io/address/0xfe9885baff18074846aaa2d5541581adf068731d#code;

const contract = new ethers.Contract(
  StargazerSampleTokenAddress,
  StargazerSampleTokenABI,
  signer
);

const receiverAddress = "0x....";
const receiveValue = ethers.utils.parseUnits("10", 18).toHexString(); // 10 SST

// We send a transaction to the network
const trxResponse = await contract.transfer(receiverAddress, receiveValue);

// We wait for confirmation
const trxReceipt = await library.waitForTransaction(trxResponse.hash);

console.log(trxReceipt.blockNumber);
// 12415408

TypeScript

import * as ethers from "ethers";

const ethersProvider = new ethers.providers.Web3Provider(ethProvider);

const signer = ethersProvider.getSigner();

const StargazerSampleTokenAddress =
  "0xfe9885baff18074846aaa2d5541581adf068731d";
const StargazerSampleTokenABI = [...[]]; // You can get StargazerSampleToken's ABI from https://sepolia.etherscan.io/address/0xfe9885baff18074846aaa2d5541581adf068731d#code;

const contract = new ethers.Contract(
  StargazerSampleTokenAddress,
  StargazerSampleTokenABI,
  signer
);

const spenderAddress = "0x....";
const spendValue = ethers.utils.parseUnits("10", 18).toHexString(); // 10 SST

// We send a transaction to the network
const trxResponse = await contract.approve(spenderAddress, spendValue);

// We wait for confirmation
const trxReceipt = await library.waitForTransaction(trxResponse.hash);

console.log(trxReceipt.blockNumber);
// 12415408

TypeScript

import * as ethers from "ethers";

const ethersProvider = new ethers.providers.Web3Provider(ethProvider);

const oneGwei = ethers.BigNumber.from(1 * 1e9).toHexString();

const signer = ethersProvider.getSigner();

// We send a transaction to the network
const trxResponse = await signer.sendTransaction({
  to: "0x....",
  value: oneGwei,
});

// We wait for confirmation
const trxReceipt = await library.waitForTransaction(trxResponse.hash);

console.log(trxReceipt.blockNumber);
// 12415408

For interaction with ethereum smart contracts you can use the RPC method and the RPC method, respectively for read and write operations. In the following example we will be using the package, and a from the . The package will help us encode method parameters based on the contract's ABI. It is encouraged to use external libraries to encode contract call parameters.

Interaction with smart contracts is done through an ABI (Application Binary Interface), you can read more about it in the article from the .

Send an ETH read call

In the next example we will use the greet method from the contract. It reads a greet string saved in the network state. For interacting with the contract we will create an ethers instance, and therefore an ethers . In the background the package will call for us.

Send an ETH contract write call

In the next example we will use the setGreeting method from the contract. It sets a greet string in the network state. For interacting with the contract we will create an ethers instance, and therefore an ethers . In the background the package will call for us.

Write calls need to be confirmed by the user. Read more .

Send ETH Transactions

As the ethereum chain reveals the RPC method you can send any kind of transaction you need (Token Transfer, Contract Interaction, ETH Transfers, etc.).

Transfer ERC20 Tokens

You can send ERC20 tokens using the transfer method from any ERC20 contract. For interacting with the contract we will create an ethers instance, and therefore an ethers . In the background the package will call for us.

Approve ERC20 token Spend

You can approve spend of ERC20 tokens to external contracts using the approve method from any ERC20 contract. For interacting with the contract we will create an ethers instance, and therefore an ethers . In the background the package will call for us.

Send ETH

You can send ETH (The ethereum's native currency) sending a simple transaction to the network. For interacting with the network we will create an ethers and an ethers . In the background the package will call for us.

Provider Activation
​
dag_accounts
eth_accounts
dag_accounts RPC method
eth_accounts RPC method
​
eth_call
eth_sendTransaction
ethers
demo contract
Stargazer Demos
ethers
Contract ABI Specification
solidity docs
​
StargazerGreeter
Contract
Web3Provider
ethers
eth_call
​
StargazerGreeter
Contract
Web3Provider
ethers
eth_sendTransaction
​
eth_sendTransaction
​
Contract
Web3Provider
ethers
eth_sendTransaction
​
Contract
Web3Provider
ethers
eth_sendTransaction
​
Web3Provider
Signer
ethers
eth_sendTransaction
here