Only this pageAll pages
Powered by GitBook
1 of 87

Stargazer Wallet

Guide

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

API Reference

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Resources

Overview

The WalletProvider allows access to different chain providers. The WalletProvider is injected into every page you visit under window.stargazer.

Introduction

Introduction to Stargazer Wallet

Stargazer is a non-custodial multichain wallet with support for Constellation and Ethereum networks. The following documentation will guide you through integrating Stargazer Wallet into a Web3 site or app.

Available Environments​

Stargazer is currently available in the following platforms:

  • Stargazer Extension (Chrome / Brave).

  • Stargazer App (iOS).

  • Stargazer App (Android).

You can interact with the Stargazer Extension via injected javascript API. Mobile interactions are not supported at the moment.

Quick Start Demos​

A pair of interactive demo sites with implementation code are available to get started quickly with common functionality such as connecting the wallet, interacting with DAG + ETH chains, sending transactions, signing messages, and more.

The demo sites use the two most common integration strategies for Web3 sites: Standalone or Web3 React integration.

getProvider()

Returns a chain provider for the selected chain.

Info

Each provider instance is created once per network, thus 2 chain providers from the same network on the same page share the same underlying reference.

Type

getProvider(chain): ChainProvider

Parameters

Name
Type
Description

Return Type

ChainProvider - The selected chain provider. An error is thrown if chain is invalid.

Example

TypeScript

activated

Contains the status of .

Type

Boolean - Indicating if the provider is activated for the current .

Example

TypeScript

version

Contains the current wallet version.

Type

String - Version string.

Example

TypeScript

chain

"constellation" | "ethereum"

Chain name.

window.stargazer.getProvider("constellation");
// ChainProvider
provider.version;
// "3.5.2"
provider.version;
// true
activation
origin

errorTypes

Contains an object with different error classes commonly thrown.

Type

Object<ErrorTypes> - Object with error classes.

ErrorTypes

type ErrorTypes = {
  // Base Stargazer Error.
  StargazerError;

  // Errors thrown by the injected WalletProvider.
  StargazerWalletProviderError;

  // General errors thrown by a chain provider.
  StargazerChainProviderError;

  // RPC related requests errors thrown by a chain provider. Complies with EIP-1193.
  StargazerChainProviderRpcError;
};

Example

TypeScript

window.stargazer.errorTypes;
/* {
  StargazerError: ƒ,
  StargazerWalletProviderError: ƒ, 
  StargazerChainProviderError: ƒ, 
  StargazerChainProviderRpcError: ƒ
} */

version

Contains the current wallet version.

Type

String - Version string.

Example

TypeScript

provider.version;
// "3.5.2"

Chain Provider API

Overview

The ChainProvider handles access to the chain RPC methods and underlying events. It complies with the EIP-1193 standard. Besides methods from the standard it adds a couple of utility methods related to provider activation.

chain

Contains the chain name of the provider.

Type

"constellation" | "ethereum" - Chain name.

Example

TypeScript

provider.chain;
// "constellation"

Overview

Following pages describe the different RPC methods available for the user. Some of this methods trigger a popup for the user to accept like dag_signMessage.

dag_accounts

Retrieves the active account in the wallet for Constellation's provider.

Parameters

None

Return Type

DAGAddress[] - User's active account.

Important

The account returned will always be the active account in Stargazer. The response will have at most one address.

Example

await provider.request({ method: "dag_accounts", params: [] });
// ["DAG88C9WDSKH451sisyEP3hAkgCKn5DN72fuwjfX"]

dag_getBalance

Returns the current DAG balance.

Parameters

None

Return Type

String - The amount of DAG.

Example

TypeScript

await provider.request({ method: "dag_getBalance" });
// "1000"

dag_getPendingTransaction

Returns information about a pending transaction by hash.

Parameters​

Name
Type
Description

TransactionHash

String<Hash>

Hash of the selected transaction.

Return Type​

PendingTransaction | null - PendingTransaction object or null if not found.

PendingTransaction

type PendingTransaction = {
  transaction: {
    source: Address // Address of the sender
    destination: Address // Address of the receiver
    amount: Number // Amount sent in DATUM
    fee: Number // Fee sent in DATUM
    parent: {
      hash: String<Hash> // Hash of the parent transaction
      ordinal: Number // Ordinal of the parent transaction
    }
    salt: BigNumber | String // Salt
  }
  hash: String<Hash> // Hash of the transaction
  status: String // Status of the transaction. Currently there is only one status: "Waiting"
}

Example​

await provider.request({
  method: "dag_getPendingTransaction",
  params: [
    "3826c2848a477ff40e3ae27d5b9f99bd2d4a30cd2702873a740dc7c77792310a"
  ],
});

// {
//   "transaction": {
//       "source": "DAG77zerQ2BUVhtVgkmseihkEfLXieBBm57vqA4J",
//       "destination": "DAG2fMnbEmsWhgYGhvdREVELyESKUqGNTEWf4B61",
//       "amount": 100000000,
//       "fee": 0,
//       "parent": {
//           "ordinal": 31,
//           "hash": "8d521fa8590151bebb5bf47b5436a93c054486955390d84cf6844cdea275426a"
//       },
//       "salt": 8837683016871549
//   },
//   "hash": "3826c2848a477ff40e3ae27d5b9f99bd2d4a30cd2702873a740dc7c77792310a",
//   "status": "Waiting"
// }

dag_requestAccounts

Important

This method will send a wallet activation request if the user hasn't activated their wallet in your dapp, you can read more about the Stargazer wallet activation process here.

Request the user to grant access to their Constellation accounts. This method follows the EIP-1102 specification.

Parameters

None

Return Type

DAGAddress[] - User accounts available.

Important

The account at index 0 will always be the active account in Stargazer.

Example

await provider.request({ method: "dag_requestAccounts", params: [] });
// ["DAG88C9WDSKH451sisyEP3hAkgCKn5DN72fuwjfX"]

Overview

Following pages describe the different RPC methods available for the user. Some of this methods trigger a popup for the user to accept like personal_sign or eth_sendTransaction.

eth_accounts

Retrieves the active account in the wallet for Ethereum's provider.

Parameters

None

Return Type

Address[] - User's active account.

Important

The account returned will always be the active account in Stargazer. The response will have at most one address.

Example

await provider.request({ method: "eth_accounts", params: [] });
// ["0x407d73d8a49eeb85d32cf465507dd71d507100c1"]

eth_gasPrice

Returns the current gas price in wei.

Parameters​

None

Return Type​

HexString<Integer> - Current gas price in wei.

Example​

TypeScript

await provider.request({
  method: "eth_gasPrice",
  params: [],
});
// "0x12a05f200"

eth_newBlockFilter

Creates a new filter in the node. Used to notify when a new block arrived. To check for state changes call eth_getFilterChanges.

Parameters​

None

Return Type​

HexString<FilterId> - The new associated filter id.

Example​

await provider.request({
  method: "eth_newBlockFilter",
  params: [],
});
// "0x81440bfbd6138ec9fe6d6ec4398b0b4879fb182f3cd8"

eth_signTypedData_v4

Calculates an ethereum signature of the given typed structured data from the selected account.

Important

Alias of eth_signTypedData

Constellation RPC API

Standalone

Standalone integration examples using the global window.stargazer object directly

Web3 react

Integration examples using Web3React and the Stargazer Wallet Connector package.

Cover
Cover

Wallet provider API

on()

EIP-1193 events

Registers the listener function as callback of the selected RPC event.

Warning

This method will always return, even if there are errors while adding the listener, for controlling errors generated during the registration process use async onAsync(eventName, listener).

Type

on(eventName, listener): void

Parameters

Name
Type
Description

eventName

String

Event to listen. Depeding on the provider chain one of or an .

listener

()=>any

Callback function.

Return Type

void

Example

TypeScript

provider.on("accountsChanged", () => {
  // Do something when accounts changed
});

removeListener()

EIP-1193 events

Removes the listener function as callback of the selected RPC event.

Warning

This method will always return, even if there are errors while removing the listener, for controlling errors generated during the deregistration process use async removeListenerAsync(eventName, listener).

Type

removeListener(eventName, listener): void

Parameters

Name
Type
Description

eventName

String

Event listened. Depeding on the provider chain one of or an .

listener

()=>any

Callback function.

Return Type

void

Example

TypeScript

provider.removeListener("accountsChanged", listener);

async removeListenerAsync()

Removes the listener function as callback of the selected RPC event.

Type

async removeListenerAsync(eventName, listener): void

Parameters

Name
Type
Description

eventName

String

Event listened. Depeding on the provider chain one of or an .

listener

()=>any

Callback function.

Return Type

void

Example

TypeScript

await provider.removeListenerAsync("accountsChanged", listener);

Provider Activation

Provider Activation

A chain provider allows you to interact with any available network. In this guide, you will learn how to obtain a chain provider and activate it.

Tip

With the Stargazer Extension installed you can test the following examples in the browser console ().

Detect Stargazer

The Stargazer browser extension injects a instance under window.stargazer each time a page loads. You can check the existence of this property using the following snippet.

TypeScript

Copy

Obtain a ChainProvider

Once you've verified your app has access to a instance you can obtain a to interact with a network of your choice (Constellation or Ethereum).

TypeScript

Copy

Read more about the and the .

Activate your provider

Activating the provider is required before it can be used to interact with the user's wallet. When activation is triggered, a popup is triggered for the user to allow your site access to their wallet. The user may choose a subset of their wallets to share if they have multiple. Activation can be achieved with one of the following methods.

Using dag_requestAccounts or eth_requestAccounts RPC methods

Calling dag_requestAccounts or eth_requestAccounts RPC methods, depending on the provider being used, will send an activation request for the user to accept. If the user accepts the request, the RPC method will return available accounts for the provider; if not, it will throw an error.

TypeScript

Copy

Read more about the different RPC methods available both for and .

Activate method (deprecated)

Warning

This method of activation has been deprecated in favor of the specification, in both Constellation and Ethereum providers.

You can send an activation request to the user using the provider's method. Once the user accepts the request you'll be able to use the provider's RPC interface and methods for the selected chain.

TypeScript

Copy

Read more about the different RPC methods available both for and .

Scope of the activation

Activations are issued for the page and cover all chains available (currently Constellation and Ethereum) and on all providers given. If you have been granted activation in the past the user will not be asked to grant it again. If the user is logged out, they will be prompted to log in again.

ChainProvider identity

All chain providers are instantiated once per page, and per chain with the following setup:

TypeScript

Copy

Two chain providers from the same network and page will share the same underlying reference:

  • Object.is(constellationProviderA, constellationProviderB) will be true.

  • Object.is(ethereumProviderA, ethereumProviderB) will be true.

  • Object.is(constellationProviderA, ethereumProviderB) will be false.

  • Object.is(constellationProviderB, ethereumProviderA) will be false.

async activate()

Sends an request for the user to accept. If the user has already given authorization for the current this method just configures the underlying communication channel.

Type

async activate(title?): boolean

Parameters

Name
Type
Description

Return Type

Boolean - Indicating the result of the activation request.

Example

TypeScript

async onAsync()

Registers the listener function as callback of the selected RPC event.

Type

async onAsync(eventName, listener): void

Parameters

Name
Type
Description

Return Type

void

Example

TypeScript

async request()

Invokes the selected RPC method. Depeding on the provider chain it will invoke a or an .

Type

async request(request): any

Parameters

Name
Type
Description

Request

Return Type

Any - Data returned from the request, depends on the invoked RPC method.

Example

TypeScript

dag_getMetagraphBalance

Returns the balance of the selected metagraph token.

Parameters

Name
Type
Description

Return Type

String - Balance of the selected metagraph token

Example

dag_getPublicKey

Returns the public key of the selected account.

Parameters

Name
Type
Description

Return Type

HexString - Public key of the selected account.

Example

dag_sendMetagraphTransaction

Sends a new transaction to the selected metagraph.

Parameters

Name
Type
Description

Transaction

Return Type

String<Hash> - The hash of the sent transaction.

Example

dag_sendMetagraphDataTransaction

Sends a new data transaction to the selected metagraph.

Parameters

Name
Type
Description

SendDataTransactionResponse

Return Type

Object<SendDataTransactionResponse> - An object that includes both transaction hash and fee hash (optional)

Example

dag_signMetagraphDataTransaction

Sends a new data transaction to the selected metagraph and returns signatures in the response.

Parameters

Name
Type
Description

SignDataTransactionResponse

Return Type

Object<SignDataTransactionResponse> - An object that includes transaction hash, fee hash (optional), signature and feeSignature (optional)

Example

dag_sendTransaction

Sends a new transaction to the Constellation network.

Parameters

Name
Type
Description

Transaction

Return Type

String<Hash> - The hash of the sent transaction.

Example

wallet_watchAsset

Adds an L0 token to the Stargazer wallet.

Parameters

Name
Type
Description

WatchAssetParameters

WatchAssetOptions

Return Type

String<Boolean> - True if the token was added successfully.

Example

dag_delegatedStake

Delegates a DAG amount to a specific node on the network.

Parameters

Name
Type
Description

DelegatedStake

The tokenLockRef value must reference a token lock transaction with an unlockEpoch value set to null and currencyId set to null (DAG). Check the details in the dag_tokenLock section.

Return Type

String<Hash> - The hash of the delegate stake transaction.

Example

dag_withdrawDelegatedStake

Withdraws a delegated stake

Parameters

Name
Type
Description

WithdrawDelegatedStake

Return Type

String<Hash> - The hash of the withdraw delegated stake transaction.

Example

dag_tokenLock

Locks a specified amount of tokens of a metagraph token or DAG.

Parameters

Name
Type
Description

TokenLock

The currentEpoch value can be pulled from the latest global snapshot. You can use dag4.js to easily get it:

Return Type

String<Hash> - The hash of the token lock transaction.

Example

eth_blockNumber

eth_blockNumber

Returns the number of the latest block mined.

Parameters

None

Return Type

HexString<Integer> - Number of the latest block.

Example

eth_getCode

Returns the compiled smart contract code, if any, at a given address.

Parameters

Name
Type
Description

Return Type

HexString - The compiled smart contract code, if any.

Example

eth_getStorageAt

Returns the value from a storage slot position at a given address.

Parameters

Name
Type
Description

Return Type

HexString - Hex code of the integer indicating the value of the storage position at the provided address.

Example

eth_getUncleCountByBlockNumber

Returns the number of uncles in a block by number.

Parameters

Name
Type
Description

Return Type

HexString<Number> | null - Number of uncles in the block or null if not found.

Example

eth_newFilter

Creates a new filter in the node, based on filter options. Used to notify state changes (logs). To check for state changes call .

Parameters

Name
Type
Description

Filter

Return Type

HexString<FilterId> - The new associated filter id.

Example

eth_protocolVersion

Returns the current ethereum protocol version.

Parameters

None

Return Type

HexString - The current ethereum protocol version.

Example

eth_sendTransaction

Sends a new transaction to the network. If the transaction has no recipient and contains data, it creates a new contract. If the transaction has a recipient and data it executes a write contract call.

Parameters

Name
Type
Description

Transaction

Return Type

HexString<Hash> - The keccak-256 digest of the sent transaction.

Example

personal_sign

Calculates an ethereum signature of the given data from the selected account.

Warning

This method adds the standard "\x19Ethereum Signed Message:\n" + len(message) prefix when calculating the signature hash.

ecdsa(keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))

Parameters

Name
Type
Description

Return Type

HexString<Signature> - The ethereum ecdsa signature.

Example

Overview

eventName

String

Event to listen. Depeding on the provider chain one of Constellation RPC event or an Ethereum RPC event.

listener

()=>any

Callback function.

await provider.onAsync("accountsChanged", () => {
  // Do something when accounts changed
});

metagraphAddress

DAGAddress

The address of the metagraph token

await provider.request({
  method: "dag_getMetagraphBalance",
  params: ["DAG0KheCYqEmFoQEWdFwrZGaXabJsWJyUvjpsLjE"],
});
// "1000"

address

DAGAddress

Account to get the public key from.

await provider.request({
  method: "dag_getPublicKey",
  params: ["DAG88C9WDSKH451sisyEP3hAkgCKn5DN72fuwjfX"],
});
// "0482c4566a9c4cbb6f23b9a31c96876501c71f5c04b35f416e0b2243113cce8fb386a2db0b3881d1c908d33465748b948649165a6705904120238999eed6eed1f4"

Data

Object<Transaction>

The transaction object.

type Transaction = {
  metagraphAddress: Address; // Address of the metagraph
  source: Address; // Address of the sender.
  destination: Address; // Address of the receiver.
  amount: Number; // Amount sent with this transaction to the receiver. (8 decimals)
  fee?: Number; // Fee used for the transaction. (8 decimals)
};
await provider.request({
  method: "dag_sendMetagraphTransaction",
  params: [
    {
      metagraphAddress: "DAG0KheCYqEmFoQEWdFwrZGaXabJsWJyUvjpsLjE",
      source: "DAG77zerQ2BUVhtVgkmseihkEfLXieBBm57vqA4J",
      destination: "DAG2fMnbEmsWhgYGhvdREVELyESKUqGNTEWf4B61",
      amount: 100000000,
      fee: 0,
    },
  ],
});
// "2d9fe9bad17debed7c903f22b74aac8af270daea7995dd099a58d6b201547169"

MetagraphId

String

The metagraph id.

Data

Object<any>

The transaction data object.

type SendDataTransactionResponse = {
  hash: string;
  feeHash?: string;
};
await provider.request({
  method: "dag_sendMetagraphDataTransaction",
  params: [
    "DAG1ocZbNdp8GYAktqwjVyCRR1CpqaUQNi82gUwk",
    {
      MintCollection: {
        name: "One collection"
      }
    }
  ],
});

//  { 
//    hash: "2d9fe9bad17debed7c903f22b74aac8af270daea7995dd099a58d6b201547169", 
//    feeHash: "0a5feeeac5a0c62f776c9b4bd887c77caf495c331c94fa5d43d7a2bbf24e3ef1"
//  }

MetagraphId

String

The metagraph id.

Data

Object<any>

The transaction data object.

type SignDataTransactionResponse = {
  hash: string;
  feeHash?: string;
  signature: string;
  feeSignature?: string;
};
await provider.request({
  method: "dag_signMetagraphDataTransaction",
  params: [
    "DAG1ocZbNdp8GYAktqwjVyCRR1CpqaUQNi82gUwk",
    {
      MintCollection: {
        name: "One collection"
      }
    }
  ],
});

//  { 
//    hash: "2d9fe9bad17debed7c903f22b74aac8af270daea7995dd099a58d6b201547169", 
//    feeHash: "0a5feeeac5a0c62f776c9b4bd887c77caf495c331c94fa5d43d7a2bbf24e3ef1",
//    signature: "3045022100b35798008516373fcc6eef75fe8e322ce8fe0dccc4802b052f3ddc7c6b5dc2900220154cac1e4f3e7d9a64f4ed9d2a518221b273fe782f037a5842725054f1c62280",
//    feeSignature: "5432022100b35798008516373fcc6eef75fe8e322ce8fe0dccc4802b052f3ddc7c6b5dc2900220154cac1e4f3e7d9a64f4ed9d2a518221b273fe782f037a5842725054f1c62280"
//  }

Data

Object<Transaction>

The transaction object.

type Transaction = {
  source: Address // Address of the sender.
  destination: Address // Address of the receiver.
  amount: Number // DATUM sent with this transaction to the receiver.
  fee?: Number // DATUM fee used for the transaction.
}
await provider.request({
  method: "dag_sendTransaction",
  params: [
    {
      source: "DAG77zerQ2BUVhtVgkmseihkEfLXieBBm57vqA4J",
      destination: "DAG2fMnbEmsWhgYGhvdREVELyESKUqGNTEWf4B61",
      amount: 100000000, // 100000000 DATUM = 1 DAG
      fee: 0,
    },
  ],
});
// "2d9fe9bad17debed7c903f22b74aac8af270daea7995dd099a58d6b201547169"

Data

Object<WatchAssetParameters>

The L0 token info object.

type WatchAssetParameters = {
  type: String; // The token's interface. "L0" is the only supported type.
  options: WatchAssetOptions;
};
type WatchAssetOptions = {
  chainId: Number; // The chain ID. 1 (mainnet), 3 (testnet), 4 (integrationnet)
  address: Address; // Metagraph address
  l0: String; // L0 endpoint
  l1: String; // L1 endpoint
  name: String; // Name of the token
  symbol: String; // Symbol of the token
  logo: String; // Logo of the token
};
await provider.request({
  method: "wallet_watchAsset",
  params: [
    {
      type: "L0",
      options: {
        chainId: 4, // IntegrationNet
        address: "DAG5kfY9GoHF1CYaY8tuRJxmB3JSzAEARJEAkA2C", // DOR Metagraph address
        l0: "http://54.218.46.24:7000",
        l1: "http://54.218.46.24:8000",
        name: "IntegrationNet DOR",
        symbol: "iDOR",
        logo: "https://.../logo.png",
      },
    },
  ],
});
// true

Data

Object<DelegatedStake>

The delegate stake object.

type DelegatedStake = {

  source: string;           // Wallet address signing the transaction

  nodeId: string;           // The node identifier to delegate stake to
                            // Must be a valid node ID

  amount: number;           // The amount to stake
                            // Must be in DATUM

  fee?: number;             // The fee in DATUM
                            // If not provided, the default fee will be 0

  tokenLockRef: string;     // Reference to the token lock transaction
                            // Must be a valid token lock transaction hash

};
await provider.request({
  method: "dag_delegatedStake",
  params: [ 
    { 
        source: 'DAG5sz69nNwGF8ypn1yukFpg2pVJpdx5mnf1PJVc',
        nodeId: '65b0c6ac3d0df47d7e7c275ac2d439d11dd73d67bca59cc9771ab7868d4a3e9e8a10661541932af394ca741765bd4d5807f030a3217553db75f050f7e65193fd',
        amount: 100000000,
        fee: 0,
        tokenLockRef: '6c6ced4c67c931e71ecbe4bbf73462c1fe51522888620683e94faf7930a989da',
    }
  ]
});
// "e041960eaea9d21760dc1c291e9ef96429e4cdbbeec2ffd504d4c2ebcc8cad45"

Data

Object<WithdrawDelegatedStake>

The withdraw delegated stake object.

type WithdrawDelegatedStake = {

  source: string;      // Wallet address signing the transaction

  stakeRef: string;    // Reference to the delegated stake transaction
                       // Must be a valid delegated stake transaction hash

};
await provider.request({
  method: "dag_withdrawDelegatedStake",
  params: [ 
    { 
        source: 'DAG5sz69nNwGF8ypn1yukFpg2pVJpdx5mnf1PJVc',
        stakeRef: '6c6ced4c67c931e71ecbe4bbf73462c1fe51522888620683e94faf7930a989da',
    }
  ]
});
// "e041960eaea9d21760dc1c291e9ef96429e4cdbbeec2ffd504d4c2ebcc8cad45"

Data

Object<TokenLock>

The token lock object.

type TokenLock = {

  source: string;             // Wallet address signing the transaction

  amount: number;             // The amount to lock
                              // Must be in DATUM

  currencyId: string | null;  // The currency metagraph identifier that the user wants to lock
                              // For DAG, this field must be null

  fee?: number;               // The fee in the currency of the currency metragraph, or DAG. 
                              // If not provided, the default fee will be 0
                              // Must be in DATUM

  unlockEpoch: number | null; // The global snapshot epoch progress to unlock the tokens
                              // If provided, must be greater than the currentEpoch

};
const latestSnapshot = await dag4.network.l0Api.getLatestSnapshot();
const currentEpoch = latestSnapshot.value.epochProgress;
await provider.request({
  method: "dag_tokenLock",
  params: [ 
    { 
        source: 'DAG5sz69nNwGF8ypn1yukFpg2pVJpdx5mnf1PJVc',
        amount: 100000000,
        currencyId: 'DAG8RdiwFhZcLmjrsz79jiKfstQmPaSqABphCK1P',
        fee: 0,
        unlockEpoch: 1022060,
    }
  ]
});
// "2d9fe9bad17debed7c903f22b74aac8af270daea7995dd099a58d6b201547169"
Constellation RPC event
Ethereum RPC event
Constellation RPC event
Ethereum RPC event
Constellation RPC event
Ethereum RPC event
if (window.stargazer) {
  console.log("Stargazer version " + window.stargazer.version + " detected");
} else {
  console.log("Stargazer not detected");
}
const provider = window.stargazer.getProvider("constellation");
await dagProvider.request({ method: "dag_requestAccounts", params: [] });
// ["DAG88C9WDSKH451sisyEP3hAkgCKn5DN72fuwjfX"] provider was activated

await ethProvider.request({ method: "eth_requestAccounts", params: [] });
// ["0xAab2C30c02016585EB36b7a0d5608Db787c1e44E"] provider was activated
const activated = await provider.activate("A Cool App Name");
const constellationProviderA = window.stargazer.getProvider("constellation");
const constellationProviderB = window.stargazer.getProvider("constellation");

const ethereumProviderA = window.stargazer.getProvider("ethereum");
const ethereumProviderB = window.stargazer.getProvider("ethereum");
devtools
​
WalletProvider
​
WalletProvider
ChainProvider
WalletProvider API
ChainProvider API
​
​
Constellation
Ethereum
​
EIP-1102
activate()
Constellation
Ethereum
​
origin
​

title?

String

App name.

await provider.activate();
// true
activation
origin

request

Request

Request method and parameters.

type Request = {
  readonly method: string;
  readonly params?: any[];
};
await provider.request({ method: "dag_accounts", params: [] });
// ["DAG88C9WDSKH451sisyEP3hAkgCKn5DN72fuwjfX"]
EIP-1193 request()
Constellation RPC method
Ethereum RPC method
await provider.request({ method: "eth_blockNumber", params: [] });
// "0xe659e6"
​
​
​

Address

Address

Address of the contract.

await provider.request({
  method: "eth_getCode",
  params: ["0x06012c8cf97bead5deae237070f9587f8e7a266d"],
});
// "0x60606040..."
​
​
​

Address

Address

Address to retrieve data from.

Position

HexString

Hex code of the position in storage.

BlockNumber

HexString<Number>| "latest" | "earliest" | "pending"

Hexadecimal block number, or the string "latest", "earliest" or "pending".

await provider.request({
  method: "eth_getStorageAt",
  params: [
    "0x295a70b2de5e3953354a6a8344e616ed314d7251",
    "0x6661e9d6d8b923d5bbaab1b96e1dd51ff6ea2a93520fdc9eb75d059238b8c5e9",
    "0x65a8db",
  ],
});
// "0x0000000000000000000000000000000000000000000000000000000000000000"
​
​
​

BlockNumber

HexString<Number>| "latest" | "earliest" | "pending"

Hexadecimal block number, or the string "latest", "earliest" or "pending".

await provider.request({
  method: "eth_getUncleCountByBlockNumber",
  params: ["0x5bad55"],
});
// "0x1"
​
​
​

Filter

Filter

Filter logs based on this filter.

type Filter = {
  address?: Address; // Address from which logs generated.
  fromBlock?: HexString<Number> | "latest" | "earliest" | "pending"; // Block number or string the string "latest", "earliest" or "pending" to search from.
  toBlock?: HexString<Number> | "latest" | "earliest" | "pending"; // Block number or string the string "latest", "earliest" or "pending" to search to.
  topics?: HexString<Topic>[]; // Array of 0 - 4 topics.
  blockHash?: HexString<Hash>; // Block from which logs generated.
};
await provider.request({
  method: "eth_newFilter",
  params: [
    {
      topics: [
        "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
      ],
    },
  ],
});
// "0x10ff0bfba9472c87932c56632eef8f5cc70910e8e71d"
eth_getFilterChanges
​
​
​
await provider.request({
  method: "eth_protocolVersion",
  params: [],
});
// "0x3f"
​
​
​

Data

Object<Transaction>

The transaction object.

type Transaction = {
  from: Address // The account the transaction is sent from.
  to?: Address // The transaction recipient.
  gas?: Number ?? 90000 // Gas units provided for transaction executon. It will return unused gas.
  gasPrice?: Number ?? currentGasPrice() // WEI paid for each gas unit used.
  value?: Number // WEI sent with this transaction to the recipient.
  data?: HexData // Encoded contract code or encoded contract call data.
}
await provider.request({
  method: "eth_sendTransaction",
  params: [
    {
      from: "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
      to: "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
      gas: "0x76c0", // 30400
      gasPrice: "0x9184e72a000", // 10000000000000
      value: "0x9184e72a", // 2441406250
      data: "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675",
    },
  ],
});
// "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331"
​
​
​

Data

HexString | String

Data to sign.

Account

Address

Account to sign from.

await provider.request({
  method: "personal_sign",
  params: ["0xdeadbeaf", "0x9b2055d370f73ec7d8a03e965129118dc8f5bf83"],
});
// "0xa3f20717a250c2b0b729b7e5becbff67fdaef7e0699da4de7ca5895b02a170a12d887fd3b17bfdce3481f10bea41f45ba9f709d39ce8325427b57afcfc994cee1b"
​
​
​

Using External Libraries

Sending raw RPC requests can be error-prone and sometimes overwhelming. This guide will list some common external libraries for the Ethereum ecosystem that are compatible with the Stargazer ChainProvider.

Ethers.js​

The ethers.js package is a general purpose library for interacting with the ethereum ecosystem. It offers different features from contract interaction to EIP-712 message signing for wallets.

In ethers.js there are different types of providers, the Stargazer ChainProvider is compatible with ethers.js Web3Provider.

import * as ethers from "ethers";

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

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

Once the ethers.js Web3Provider is created you can start interacting with the network using this library.

// get balance from address
await ethersProvider.getBalance("0xEb14c9bb6C2DEc2eCb9B278C9fa1EC763B04d545");
// { BigNumber: "36428926959297445147" }
// get current block number
await ethersProvider.getBlockNumber();
// 14983198
// get current gas price
await ethersProvider.getGasPrice();
// { BigNumber: "23610503242" }

Web3.js​

The web3.js library offers a simple but powerful API to interact with the ethereum ecosystem using EIP-1193, HTTP, IPC or WebSocket providers.

The web3.js library reveals the Web3 class which is compatible with the Stargazer ChainProvider.

import Web3 from "web3";

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

const web3Provider = new Web3(ethProvider);

Once the web3.js Web3 object is created you can start interacting with the network using this library.

// get balance from address
await web3Provider.eth.getBalance("0xEb14c9bb6C2DEc2eCb9B278C9fa1EC763B04d545");
// "36428926959297445147"
// get current block number
await web3Provider.eth.getBlockNumber();
// 14983198
// get current gas price
await web3Provider.eth.getGasPrice();
// "23610503242"

dag_getMetagraphPendingTransaction

Returns information about a pending transaction by hash in a specific metagraph.

Parameters​

Name
Type
Description

Data

Object<PendingTransactionParams>

Transaction info object

TransactionParams

type PendingTransactionParams = {
  metagraphAddress: String; // Metagraph address
  hash: String; // Hash of the transaction
};

Return Type​

PendingTransaction | null - PendingTransaction object or null if not found.

PendingTransaction

type PendingTransaction = {
  transaction: {
    source: Address; // Address of the sender
    destination: Address; // Address of the receiver
    amount: Number; // Amount sent
    fee: Number; // Fee sent
    parent: {
      hash: String<Hash>; // Hash of the parent transaction
      ordinal: Number; // Ordinal of the parent transaction
    };
    salt: BigNumber | String; // Salt
  };
  hash: String<Hash>; // Hash of the transaction
  status: String; // Status of the transaction. Currently there is only one status: "Waiting"
};

Example​

await provider.request({
  method: "dag_getMetagraphPendingTransaction",
  params: [
    {
      metagraphAddress: "DAG0KheCYqEmFoQEWdFwrZGaXabJsWJyUvjpsLjE",
      hash: "3826c2848a477ff40e3ae27d5b9f99bd2d4a30cd2702873a740dc7c77792310a",
    },
  ],
});

// {
//   "transaction": {
//       "source": "DAG77zerQ2BUVhtVgkmseihkEfLXieBBm57vqA4J",
//       "destination": "DAG2fMnbEmsWhgYGhvdREVELyESKUqGNTEWf4B61",
//       "amount": 100000000,
//       "fee": 0,
//       "parent": {
//           "ordinal": 31,
//           "hash": "8d521fa8590151bebb5bf47b5436a93c054486955390d84cf6844cdea275426a"
//       },
//       "salt": 8837683016871549
//   },
//   "hash": "3826c2848a477ff40e3ae27d5b9f99bd2d4a30cd2702873a740dc7c77792310a",
//   "status": "Waiting"
// }

eth_estimateGas

Generates an estimate of how much gas will be necessary to process a transaction on the blockchain. Generally the estimate is significantly greater than the actual gas used. The transaction will not be added to the blockchain.

Parameters​

Name
Type
Description

Data

Object<Transaction>

The transaction object.

Transaction

type Transaction = {
  from: Address // The account the transaction is sent from.
  to?: Address // The transaction recipient.
  gas?: Number ?? 90000 // Gas units provided for transaction executon. It will return unused gas.
  gasPrice?: Number ?? currentGasPrice() // WEI paid for each gas unit used.
  value?: Number // WEI sent with this transaction to the recipient.
  data?: HexData // Encoded contract call data.
}

Return Type​

HexString<Integer> - Estimate in gas units.

Example​

TypeScript

await provider.request({
  method: "eth_estimateGas",
  params: [
    {
      from: "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
      to: "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
      gas: "0x76c0",
      gasPrice: "0x9184e72a000",
      value: "0x9184e72a",
      data: "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675",
    },
  ],
});
// "0x5cec"

eth_call

Executes a new message call immediately without creating a transaction on the blockchain.

Parameters​

Name
Type
Description

Data

Object<Transaction>

The transaction object.

Block

Number | "latest" | "earliest" | "pending"

Block number to execute this call in.

Transaction

type Transaction = {
  from: Address // The account the transaction is sent from.
  to?: Address // The transaction recipient.
  gas?: Number ?? 90000 // Gas units provided for transaction executon. It will return unused gas.
  gasPrice?: Number ?? currentGasPrice() // WEI paid for each gas unit used.
  value?: Number // WEI sent with this transaction to the recipient.
  data?: HexData // Encoded contract call data.
}

Return Type​

HexString<Any> - The returned data of the contract execution.

Example​

await provider.request({
  method: "eth_call",
  params: [
    {
      from: "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
      to: "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
      gas: "0x76c0", // 30400
      gasPrice: "0x9184e72a000", // 10000000000000
      value: "0x9184e72a", // 2441406250
      data: "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675",
    },
    "latest",
  ],
});
// "0x9184e8f"

eth_getBlockTransactionCountByNumber

Returns the number of transactions included in a block by number.

Parameters​

Name
Type
Description

BlockNumber

HexString<Number>| "latest" | "earliest" | "pending"

Hexadecimal block number, or the string "latest", "earliest" or "pending".

Return Type​

HexString<Number> | null - Number of transactions included in the block or null if not found.

Example​

await provider.request({
  method: "eth_getBlockTransactionCountByNumber",
  params: ["0x5bad55"],
});
// "0x50"

eth_getTransactionCount

Returns the number of transactions sent from address.

Parameters​

Name
Type
Description

Address

Address

Address to fetch count for.

BlockNumber

HexString<Number>| "latest" | "earliest" | "pending"

Hexadecimal block number, or the string "latest", "earliest" or "pending".

Return Type​

HexString<Number> - Number of transactions sent from address.

Example​

await provider.request({
  method: "eth_getTransactionCount",
  params: ["0xc94770007dda54cF92009BFF0dE90c06F603a09f", "0x5bad55"],
});
// "0x1a"

eth_getBalance

Returns the balance of the account of given address.

Parameters​

Name
Type
Description

Account

Address

Account to check for balance.

Block

Number | "latest" | "earliest" | "pending"

Block number to execute this call in.

Return Type​

HexString<Integer> - The current balance of the selected block in wei.

Example​

await provider.request({
  method: "eth_getBalance",
  params: ["0xc94770007dda54cF92009BFF0dE90c06F603a09f", "latest"],
});
// "0x2fe84e3113d7b"

eth_getUncleCountByBlockHash

Returns the number of uncles in a block by hash.

Parameters​

Name
Type
Description

BlockHash

HexString<Hash>

Hash of the selected block.

Return Type​

HexString<Number> | null - Number of uncles in the block or null if not found.

Example​

await provider.request({
  method: "eth_getUncleCountByBlockHash",
  params: [
    "0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35",
  ],
});
// "0x1"

net_version

Returns the current network id.

Parameters​

None

Return Type​

ChainId - The current network id. The full list of chain IDs is available at chainlist.org. Some of the common ones are noted bellow.

ChainId

type ChainId =
  | "1" // Ethereum Mainnet
  | "2" // Morden Testnet (deprecated)
  | "3" // Ropsten Testnet
  | "4" // Rinkeby Testnet
  | "5" // Goerli Testnet
  | "11155111"; // Sepolia TestNet

Example​

await provider.request({ method: "net_version", params: [] });
// "3"

eth_requestAccounts

Important

This method will send a wallet activation request if the user hasn't activated their wallet in your dapp, you can read more about the Stargazer wallet activation process here.

Request the user to grant access to their Ethereum (EVM) accounts. This method follows the EIP-1102 specification.

Parameters​

None

Return Type​

Address[] - User accounts available.

Important

The account at index 0 will always be the active account in Stargazer.

Example​

await provider.request({ method: "eth_requestAccounts", params: [] });
// ["0x407d73d8a49eeb85d32cf465507dd71d507100c1"]

eth_getBlockTransactionCountByHash

Returns the number of transactions included in a block by hash.

Parameters​

Name
Type
Description

BlockHash

HexString<Hash>

Hash of the selected block.

Return Type​

HexString<Number> | null - Number of transactions included in the block or null if not found.

Example​

await provider.request({
  method: "eth_getBlockTransactionCountByHash",
  params: [
    "0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35",
  ],
});
// "0x50"

eth_uninstallFilter

Uninstalls a filter with given ID. Should always be called when watching is no longer needed. Additionally filters time out when they aren't requested with eth_getFilterChanges for a period of time.

Parameters​

Name
Type
Description

FilterId

HexString

Filter to uninstall by id.

Return Type​

Boolean - True if the filter was uninstalled successfully.

Example​

await provider.request({
  method: "eth_uninstallFilter",
  params: ["0x10ff0bfba9472c87932c56632eef8f5cc70910e8e71d"],
});
// true

Overview

The following pages will cover various classes and interfaces found while using the Stargazer Wallet API in the browser.

dag_getTransaction

Returns information about a transaction by hash. If the transaction object is returned, the transaction was included in a block and lives in the network.

Parameters

Name
Type
Description

Return Type

Transaction | null - Transaction object or null if not found.

Transaction

Proof

Example

dag_signData

Creates a request to generate a safe signature of arbitrary data from the selected wallet. This method is intended to be used for interaction with custom data requests to metagraphs and other similar use cases.

This method adds a standard "\u0019Constellation Signed Data:\n" + len(message) + "\n" prefix when calculating the signature hash. The addition of the prefix prevents users from being tricked into signing a valid token transaction with this method.

The final string looks like this: "\u0019Constellation Signed Data:\n" + len(message) + "\n" + message

Warning

Please be sure you use the correct prefix for the correct method when verifying signatures, dag_signData uses "Constellation Signed Data:" while dag_signMessage uses "Constellation Signed Message:"

Parameters

Name
Type
Description

Return Type

HexString - The prefixed ECDSA signature.

Base64

JSONEncoded

StringEncoded

Example

Verify

In order to verify the signature you can use the verifyData() method from dag4.js:

eth_getLogs

Returns all logs matching a given filter object.

Parameters

Name
Type
Description

Filter

Return Type

Log[] - Array of log objects found.

Log

Example

eth_getTransactionByHash

Returns information about a transaction by hash.

Parameters

Name
Type
Description

Return Type

Transaction | null - Transaction object or null if not found.

Transaction

Example

eth_getFilterChanges

Returns associated logs or block hashes for the given filter id since the last poll. Filter ids must be created using or .

Parameters

Name
Type
Description

Return Type

Log[] | HexString<Hash>[] - Array of log objects found or for filters created using an array of hashes.

Log

Example

dag_allowSpend

Grants permission for another wallet or metagraph to spend up to a specified amount from the user’s wallet in a metagraph token or DAG.

Parameters

Name
Type
Description

AllowSpend

The currentEpoch value can be pulled from the latest global snapshot. You can use dag4.js to easily get it:

Return Type

String<Hash> - The hash of the allow spend transaction.

Example

web3_sha3

Returns the keccak-256 (not the standarized sha3-256) of the given data.

Parameters

Name
Type
Description

Return Type

HexString - The keccak-256 digest of the given data.

Example

Data

Object<AllowSpend>

The allow spend object.

type AllowSpend = {

  source: string;             // Wallet address signing the transaction

  destination: string;        // The destination address
                              // Must be a metagraph address

  amount: number;             // The amount to allow spend
                              // Must be in DATUM

  approvers: string[];        // An array with a single DAG address that can atomically approve this operation
                              // Can be a metagraph or wallet address

  currencyId: string | null;  // The currency metagraph identifier
                              // For DAG, this field must be null

  fee?: number;               // The fee in the currency of the currency metagraph, or DAG.
                              // If not provided, the default fee will be 0
                              // Must be in DATUM

  validUntilEpoch?: number;   // The global snapshot epoch progress for which this is valid until 
                              // If not provided, the default value will be currentEpoch + 30
                              // Minumum allowed value: currentEpoch + 5
                              // Maximum allowed value: currentEpoch + 60

};
const latestSnapshot = await dag4.network.l0Api.getLatestSnapshot();
const currentEpoch = latestSnapshot.value.epochProgress;
await provider.request({
  method: "dag_allowSpend",
  params: [ 
    { 
        source: 'DAG5sz69nNwGF8ypn1yukFpg2pVJpdx5mnf1PJVc',
        destination: 'DAG3miCyHnvuoyywvnvnMzt35Y9Gs7EqTHQx6xtg',
        amount: 100000000,
        approvers: ['DAG3miCyHnvuoyywvnvnMzt35Y9Gs7EqTHQx6xtg'],
        currencyId: 'DAG8RdiwFhZcLmjrsz79jiKfstQmPaSqABphCK1P',
        fee: 0,
        validUntilEpoch: 1022060,
    }
  ]
});
// "2d9fe9bad17debed7c903f22b74aac8af270daea7995dd099a58d6b201547169"

TransactionHash

String<Hash>

Hash of the selected transaction.

type Transaction = {
  hash: String<Hash> // Hash of the transaction
  amount: Number // Amount sent in DATUM
  source: Address // Address of the sender
  destination: Address // Address of the receiver
  fee: Number // Fee sent in DATUM
  parent: {
    hash: String<Hash> // Hash of the parent transaction
    ordinal: Number // Ordinal of the parent transaction
  } 
  blockHash: String<Hash> // Hash of the block
  snapshotHash: String<Hash> // Hash of the snapshot
  snapshotOrdinal: Number // Ordinal of the snapshot
  transactionOriginal: {
    value: {
      source: Address // Address of the sender
      destination: Address // Address of the receiver
      amount: Number // Amount sent in DATUM
      fee: Number // Fee sent in DATUM
      parent: {
        hash: String<Hash> // Hash of the parent transaction
        ordinal: Number // Ordinal of the parent transaction
      }
      salt: BigNumber | String // Salt
    }
    proofs: Proof[] // Proofs
  }
  timestamp: String // Timestamp
}
type Proof = {
  id: String // Id of the signature
  signature: String // Signature
}
await provider.request({
  method: "dag_getTransaction",
  params: [
    "5659d17c234d57c57a7335792889fe50cf66ec3d717b5d28d9bfa943e4275d27"
  ],
});

// {
//   "hash": "5659d17c234d57c57a7335792889fe50cf66ec3d717b5d28d9bfa943e4275d27",
//   "amount": 100000000,
//   "source": "DAG77zerQ2BUVhtVgkmseihkEfLXieBBm57vqA4J",
//   "destination": "DAG2fMnbEmsWhgYGhvdREVELyESKUqGNTEWf4B61",
//   "fee": 0,
//   "parent": {
//       "hash": "3826c2848a477ff40e3ae27d5b9f99bd2d4a30cd2702873a740dc7c77792310a",
//       "ordinal": 32
//   },
//   "blockHash": "f2df30d776dbf05240b14654d2e156099b25ff6e45084eac9ab89c37689a2007",
//   "snapshotHash": "f41437fc5fc01483069e8d11ff3597f4c2715f44a859432d3f0041838ff270d2",
//   "snapshotOrdinal": 509453,
//   "transactionOriginal": {
//       "value": {
//           "source": "DAG77zerQ2BUVhtVgkmseihkEfLXieBBm57vqA4J",
//           "destination": "DAG2fMnbEmsWhgYGhvdREVELyESKUqGNTEWf4B61",
//           "amount": 100000000,
//           "fee": 0,
//           "parent": {
//               "ordinal": 32,
//               "hash": "3826c2848a477ff40e3ae27d5b9f99bd2d4a30cd2702873a740dc7c77792310a"
//           },
//           "salt": 8888012531929986
//       },
//       "proofs": [
//           {
//               "id": "b85cbc0d210bfb98de58b9b1c6d195f6ee09e254e489f284756e3ebae82054823b04e64bcc62bb6b20ee8016b819419389037d8d09e278e47fe79645cfd8b166",
//               "signature": "3045022100e597cb6ac5e05e00c03998c11ed4ee0c3d8e42aedd37c19f4968ad494d5357e202205f754fe64410e2d8770b3976eb458c4bd3b22aa8f48609c2577dab88e23ef3fd"
//           }
//       ]
//   },
//   "timestamp": "2023-01-26T15:42:21.970Z"
// }
​
​
​

Account

Address

Account to sign from.

Request

Base64<JSONEncoded> | Base64<StringEncoded>

Signature Request.

/**
 * A base64 encoded string
 * */
type Base64 = string;
/**
 * A JSON encoded string
 * */
type JSONEncoded = string;
/**
 * A String encoded
 * */
type StringEncoded = string;
// Build the signature request
const signatureRequest: any = {
  field1: "content_field_1",
  field2: {
    field2_1: true,
    field2_2: 12332435,
    field2_3: {
      field2_3_1: "content_field2_3_1",
    },
  },
  field3: [1, 2, 3, 4],
  field4: null,
};

// Encode the signature request - Base64 < JSON < Request
const signatureRequestEncoded = window.btoa(JSON.stringify(signatureRequest));

// Encode the string directly if "signatureRequest" is a string:
// const signatureRequest = "This is a custom string.";
//
//                                      Base64 < String
// const signatureRequestEncoded = window.btoa(signatureRequest);

await provider.request({
  method: "dag_signData",
  params: ["DAG88C9WDSKH451sisyEP3hAkgCKn5DN72fuwjfX", signatureRequestEncoded],
});
// "3045022100b35798008516373fcc6eef75fe8e322ce8fe0dccc4802b052f3ddc7c6b5dc2900220154cac1e4f3e7d9a64f4ed9d2a518221b273fe782f037a5842725054f1c62280"
// Build the same signature request
const signatureRequest: any = {
  field1: "content_field_1",
  field2: {
    field2_1: true,
    field2_2: 12332435,
    field2_3: {
      field2_3_1: "content_field2_3_1",
    },
  },
  field3: [1, 2, 3, 4],
  field4: null,
};

// get the public key
const publicKey = await provider.request({
  method: "dag_getPublicKey",
  params: [
    "DAG88C9WDSKH451sisyEP3hAkgCKn5DN72fuwjfX", // Your DAG address
  ],
});

// same request used in dag_signData
const signatureRequestEncoded = window.btoa(JSON.stringify(signatureRequest));

// hash returned by dag_signData in the pevious example
const signature =
  "3045022100b35798008516373fcc6eef75fe8e322ce8fe0dccc4802b052f3ddc7c6b5dc2900220154cac1e4f3e7d9a64f4ed9d2a518221b273fe782f037a5842725054f1c62280";

const message = `\u0019Constellation Signed Data:\n${signatureRequestEncoded.length}\n${signatureRequestEncoded}`;

const result = await dag4.keyStore.verifyData(publicKey, message, signature);
// true -> verification succeeded
// false -> verification failed
​
​
​
​

Filter

Filter

Filter logs based on this filter.

type Filter = {
  address?: Address; // Address from which logs generated.
  fromBlock?: HexString<Number> | "latest" | "earliest" | "pending"; // Block number or string the string "latest", "earliest" or "pending" to search from.
  toBlock?: HexString<Number> | "latest" | "earliest" | "pending"; // Block number or string the string "latest", "earliest" or "pending" to search to.
  topics?: HexString<Topic>[]; // Array of 0 - 4 topics.
  blockHash?: HexString<Hash>; // Block from which logs generated.
};
type Log = {
  address: Address; // Address from which this log was generated.

  blockHash: HexString<Hash> | null; // Block hash from which this log was generated or null if transaction is pending.
  blockNumber: HexString<Number> | null; // Block number from which this log was generated or null if transaction is pending.

  transactionHash: HexString<Hash>; // Transaction hash from which this log was generated.
  transactionIndex: HexString<Number> | null; // Transaction index from which this log was generated or null if transaction is pending.

  data: HexString; // Data of non-indexed arguments for the log.
  logIndex: HexString<Number> | null; // Log index in the block or null if transaction is pending.
  removed: boolean; // True if the log was removed, due to a chain reorganization. False if it's a valid log.
  topics: HexString<Topic>[]; // Array of 0 - 4 topics.
};
await provider.request({
  method: "eth_getLogs",
  params: [
    {
      blockHash:
        "0x7c5a35e9cb3e8ae0e221ab470abae9d446c3a5626ce6689fc777dcffcab52c70",
      topics: [
        "0x241ea03ca20251805084d27d4440371c34a0b85ff108f6bb5611248f73818b80",
      ],
    },
  ],
});
/* [
  {
    address: "0x1a94fce7ef36bc90959e206ba569a12afbc91ca1",
    blockHash:
      "0x7c5a35e9cb3e8ae0e221ab470abae9d446c3a5626ce6689fc777dcffcab52c70",
    blockNumber: "0x5c29fb",
    data: "0x0000000000000000000000003e...",
    logIndex: "0x1d",
    removed: false,
    topics: [
      "0x241ea03ca20251805084d27d4440371c34a0b85ff108f6bb5611248f73818b80",
    ],
    transactionHash:
      "0x3dc91b98249fa9f2c5c37486a2427a3a7825be240c1c84961dfb3063d9c04d50",
    transactionIndex: "0x1d",
  },
  {
    address: "0x06012c8cf97bead5deae237070f9587f8e7a266d",
    blockHash:
      "0x7c5a35e9cb3e8ae0e221ab470abae9d446c3a5626ce6689fc777dcffcab52c70",
    blockNumber: "0x5c29fb",
    data: "0x0000000000000000000000007...",
    logIndex: "0x57",
    removed: false,
    topics: [
      "0x241ea03ca20251805084d27d4440371c34a0b85ff108f6bb5611248f73818b80",
    ],
    transactionHash:
      "0x788b1442414cb9c9a36dba2abe250763161a6f6395788a2e808f1b34e92beec1",
    transactionIndex: "0x54",
  },
] */
​
​
​

TransactionHash

HexString<Hash>

Hash of the selected transaction.

type Transaction = {
  hash: HexString<Hash>; // Hash of the transaction.
  from: Address; // Address of the sender.
  to: Address | null; // Address of the receiver or null for contract creations.
  value: HexString<Number>; // Value sent in WEI.

  blockHash: HexString<Hash> | null; // Block hash of transaction or null if transaction is pending.
  blockNumber: HexString<Number> | null; // Block number of transaction or null if transaction is pending.
  nonce: HexString<Number>; // Number of transactions made by the sender before.

  gas: HexString<Number>; // Gas units provider by the sender.
  gasPrice: HexString<Number>; // Gas price provider by the sender in WEI.
  maxFeePerGas?: HexString<Number>; // Maximum fee in WEI per gas unit. EIP-1559.
  maxPriorityFeePerGas?: HexString<Number>; // Maximum fee in WEI per gas unit above the base fee. EIP-1559.

  input: HexString; // Data sent with the transaction.

  r: HexString; // ECDSA signature r.
  s: HexString; // ECDSA signature s.
  v: HexString; // ECDSA recovery ID.

  transactionIndex: HexString<Number> | null; // Transaction index in block or null if transaction is pending.
  type: HexString<Number>; // Transaction type
};
await provider.request({
  method: "eth_getTransactionByHash",
  params: [
    "0xbb3a336e3f823ec18197f1e13ee875700f08f03e2cab75f0d0b118dabb44cba0",
  ],
});

/* {
  blockHash:
    "0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35",
  blockNumber: "0x5bad55",
  from: "0xfbb1b73c4f0bda4f67dca266ce6ef42f520fbb98",
  gas: "0x249f0",
  gasPrice: "0x174876e800",
  hash: "0x8784d99762bccd03b2086eabccee0d77f14d05463281e121a62abfebcf0d2d5f",
  input:
    "0x6ea056a900000000000...",
  nonce: "0x5e4724",
  r: "0xd1556332df97e3bd911068651cfad6f975a30381f4ff3a55df7ab3512c78b9ec",
  s: "0x66b51cbb10cd1b2a09aaff137d9f6d4255bf73cb7702b666ebd5af502ffa4410",
  to: "0x4b9c25ca0224aef6a7522cabdbc3b2e125b7ca50",
  transactionIndex: "0x0",
  type: "0x0",
  v: "0x25",
  value: "0x0",
} */
​
​
​

FilterId

HexString<FilterId>

Filter id created using eth_newFilter or eth_newBlockFilter.

type Log = {
  address: Address; // Address from which this log was generated.

  blockHash: HexString<Hash> | null; // Block hash from which this log was generated or null if transaction is pending.
  blockNumber: HexString<Number> | null; // Block number from which this log was generated or null if transaction is pending.

  transactionHash: HexString<Hash>; // Transaction hash from which this log was generated.
  transactionIndex: HexString<Number> | null; // Transaction index from which this log was generated or null if transaction is pending.

  data: HexString; // Data of non-indexed arguments for the log.
  logIndex: HexString<Number> | null; // Log index in the block or null if transaction is pending.
  removed: boolean; // True if the log was removed, due to a chain reorganization. False if it's a valid log.
  topics: HexString<Topic>[]; // Array of 0 - 4 topics.
};
await provider.request({
  method: "eth_getFilterChanges",
  params: ["0x10ff0bfbedb01f0dbd4106d14eb719ec38b6eb5b821c"],
});
/* [
  {
    address: "0x1a94fce7ef36bc90959e206ba569a12afbc91ca1",
    blockHash:
      "0x7c5a35e9cb3e8ae0e221ab470abae9d446c3a5626ce6689fc777dcffcab52c70",
    blockNumber: "0x5c29fb",
    data: "0x0000000000000000000000003e...",
    logIndex: "0x1d",
    removed: false,
    topics: [
      "0x241ea03ca20251805084d27d4440371c34a0b85ff108f6bb5611248f73818b80",
    ],
    transactionHash:
      "0x3dc91b98249fa9f2c5c37486a2427a3a7825be240c1c84961dfb3063d9c04d50",
    transactionIndex: "0x1d",
  },
  {
    address: "0x06012c8cf97bead5deae237070f9587f8e7a266d",
    blockHash:
      "0x7c5a35e9cb3e8ae0e221ab470abae9d446c3a5626ce6689fc777dcffcab52c70",
    blockNumber: "0x5c29fb",
    data: "0x0000000000000000000000007...",
    logIndex: "0x57",
    removed: false,
    topics: [
      "0x241ea03ca20251805084d27d4440371c34a0b85ff108f6bb5611248f73818b80",
    ],
    transactionHash:
      "0x788b1442414cb9c9a36dba2abe250763161a6f6395788a2e808f1b34e92beec1",
    transactionIndex: "0x54",
  },
] */
eth_newFilter
eth_newBlockFilter
​
​
eth_newBlockFilter
​

Data

HexString

Data to calculate the hash from.

await provider.request({
  method: "web3_sha3",
  params: ["0x68656c6c6f20776f726c64"],
});
// "0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad"
​
​
​

eth_getTransactionReceipt

Returns the receipt for a transaction by hash.

Important

The transaction receipt is only available for mined transactions.

Parameters​

Name
Type
Description

TransactionHash

HexString<Hash>

Hash of the selected transaction.

Return Type​

TransactionReceipt | null - Transaction receipt object or null if not found.

TransactionReceipt

type TransactionReceipt = {
  status: HexString<Number>; // 1 Success or 0 Failure
  from: Address; // Address of the sender.
  to: Address | null; // Address of the receiver or null for contract creations.

  blockHash: HexString<Hash> | null; // Block hash of transaction or null if transaction is pending.
  blockNumber: HexString<Number> | null; // Block number of transaction or null if transaction is pending.

  contractAddress: Address | null; // Contract address created or null if no contract was created.

  gasUsed: HexString<Number>; // Amount of gas units used by this transaction alone.
  cumulativeGasUsed: HexString<Number>; // Amount of gas units used by this transaction in the block.
  effectiveGasPrice: HexString<Number>; // Actual value per gas unit deducted from the sender's account.

  transactionHash: HexString<Hash>; // Hash of the transaction.
  transactionIndex: HexString<Number> | null; // Transaction index in block or null if transaction is pending.
  type: HexString<Number>; // Transaction type

  logs: Log[]; // Array of log objects generated from this transaction.
  logsBloom: HexString<FilterBloom> | null; // Bloom filter of the logs generated from this transaction.
};

Log

type Log = {
  address: Address; // Address from which this log was generated.

  blockHash: HexString<Hash> | null; // Block hash from which this log was generated or null if transaction is pending.
  blockNumber: HexString<Number> | null; // Block number from which this log was generated or null if transaction is pending.

  transactionHash: HexString<Hash>; // Transaction hash from which this log was generated.
  transactionIndex: HexString<Number> | null; // Transaction index from which this log was generated or null if transaction is pending.

  data: HexString; // Data of non-indexed arguments for the log.
  logIndex: HexString<Number> | null; // Log index in the block or null if transaction is pending.
  removed: boolean; // True if the log was removed, due to a chain reorganization. False if it's a valid log.
  topics: HexString<Topic>[]; // Array of 0 - 4 topics.
};

Example​

await provider.request({
  method: "eth_getTransactionReceipt",
  params: [
    "0xbb3a336e3f823ec18197f1e13ee875700f08f03e2cab75f0d0b118dabb44cba0",
  ],
});
/* {
  blockHash:
    "0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35",
  blockNumber: "0x5bad55",
  contractAddress: null,
  cumulativeGasUsed: "0xb90b0",
  effectiveGasPrice: "0x746a528800",
  from: "0x398137383b3d25c92898c656696e41950e47316b",
  gasUsed: "0x1383f",
  logs: [
    {
      address: "0x06012c8cf97bead5deae237070f9587f8e7a266d",
      blockHash:
        "0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35",
      blockNumber: "0x5bad55",
      data: "0x000000000000000000000000...",
      logIndex: "0x6",
      removed: false,
      topics: [
        "0x241ea03ca20251805084d27d4440371c34a0b85ff108f6bb5611248f73818b80",
      ],
      transactionHash:
        "0xbb3a336e3f823ec18197f1e13ee875700f08f03e2cab75f0d0b118dabb44cba0",
      transactionIndex: "0x11",
    },
  ],
  logsBloom: "0x000000000000000000000000000000...",
  status: "0x1",
  to: "0x06012c8cf97bead5deae237070f9587f8e7a266d",
  transactionHash:
    "0xbb3a336e3f823ec18197f1e13ee875700f08f03e2cab75f0d0b118dabb44cba0",
  transactionIndex: "0x11",
  type: "0x0",
} */

dag_signMessage

Creates a request to generate a safe signature of typed message data from the selected wallet. This method is intended to be used for general message signing use cases such as verifying the ownership of a wallet.

This method adds a standard "\u0019Constellation Signed Message:\n" + len(message) + "\n" prefix when calculating the signature hash. The addition of the prefix prevents users from being tricked into signing a valid token transaction with this method.

The final string looks like this: "\u0019Constellation Signed Message:\n" + len(message) + "\n" + message

Warning

Please be sure you use the correct prefix for the correct method when verifying signatures, dag_signMessage uses "Constellation Signed Message:" while dag_signData uses "Constellation Signed Data:"

Parameters​

Name
Type
Description

Account

Address

Account to sign from.

Request

Base64<JSONEncoded<SignatureRequest>>

Signature Request.

Return Type​

HexString - The constellation ecdsa signature.

Base64

/**
 * A base64 encoded string
 * */
type Base64 = string;

JSONEncoded

/**
 * A JSON encoded string
 * */
type JSONEncoded = string;

JSONScalarValue

type JSONScalarValue = null | string | number | boolean;

SignatureRequest

type SignatureRequest = {
  content: string;
  metadata: Record<string, JSONScalarValue>;
};

Example​

// Build the signature request
const signatureRequest: SignatureRequest = {
  content: "Sign this message to confirm your address",
  metadata: {
    user: "3feb69d6-d3f0-4812-9c93-384bee08afe8",
  },
};

// Encode the signature request - Base64 < JSON < Request
const signatureRequestEncoded = window.btoa(JSON.stringify(signatureRequest));

await provider.request({
  method: "dag_signMessage",
  params: ["DAG88C9WDSKH451sisyEP3hAkgCKn5DN72fuwjfX", signatureRequestEncoded],
});
// "3045022100b35798008516373fcc6eef75fe8e322ce8fe0dccc4802b052f3ddc7c6b5dc2900220154cac1e4f3e7d9a64f4ed9d2a518221b273fe782f037a5842725054f1c62280"

Verify​

In order to verify the signature you can use the verify() method from dag4.js:

// Build the same signature request
const signatureRequest: SignatureRequest = {
  content: "Sign this message to confirm your address",
  metadata: {
    user: "3feb69d6-d3f0-4812-9c93-384bee08afe8",
  },
};

// get the public key
const publicKey = await provider.request({
  method: "dag_getPublicKey",
  params: [
    "DAG88C9WDSKH451sisyEP3hAkgCKn5DN72fuwjfX", // Your DAG address
  ],
});

// same request used in dag_signMessage
const signatureRequestEncoded = window.btoa(JSON.stringify(signatureRequest));

// hash returned by dag_signMessage in the pevious example
const signature =
  "3045022100b35798008516373fcc6eef75fe8e322ce8fe0dccc4802b052f3ddc7c6b5dc2900220154cac1e4f3e7d9a64f4ed9d2a518221b273fe782f037a5842725054f1c62280";

const message = `\u0019Constellation Signed Message:\n${signatureRequestEncoded.length}\n${signatureRequestEncoded}`;

const result = await dag4.keyStore.verify(publicKey, message, signature);
// true -> verification succeeded
// false -> verification failed

eth_getTransactionByBlockNumberAndIndex

Returns information about a transaction by block number and transaction index position.

Parameters​

Name
Type
Description

BlockNumber

HexString<Number>| "latest" | "earliest" | "pending"

Hexadecimal block number, or the string "latest", "earliest" or "pending".

Index

HexString<Number>

Transaction index.

Return Type​

Transaction | null - Transaction object or null if not found.

Transaction

type Transaction = {
  hash: HexString<Hash>; // Hash of the transaction.
  from: Address; // Address of the sender.
  to: Address | null; // Address of the receiver or null for contract creations.
  value: HexString<Number>; // Value sent in WEI.

  blockHash: HexString<Hash> | null; // Block hash of transaction or null if transaction is pending.
  blockNumber: HexString<Number> | null; // Block number of transaction or null if transaction is pending.
  nonce: HexString<Number>; // Number of transactions made by the sender before.

  gas: HexString<Number>; // Gas units provider by the sender.
  gasPrice: HexString<Number>; // Gas price provider by the sender in WEI.
  maxFeePerGas?: HexString<Number>; // Maximum fee in WEI per gas unit. EIP-1559.
  maxPriorityFeePerGas?: HexString<Number>; // Maximum fee in WEI per gas unit above the base fee. EIP-1559.

  input: HexString; // Data sent with the transaction.

  r: HexString; // ECDSA signature r.
  s: HexString; // ECDSA signature s.
  v: HexString; // ECDSA recovery ID.

  transactionIndex: HexString<Number> | null; // Transaction index in block or null if transaction is pending.
  type: HexString<Number>; // Transaction type
};

Example​

await provider.request({
  method: "eth_getTransactionByBlockHashAndIndex",
  params: [
    "0x5bad55",
    "0x0",
  ],
});

/* {
  blockHash:
    "0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35",
  blockNumber: "0x5bad55",
  from: "0xfbb1b73c4f0bda4f67dca266ce6ef42f520fbb98",
  gas: "0x249f0",
  gasPrice: "0x174876e800",
  hash: "0x8784d99762bccd03b2086eabccee0d77f14d05463281e121a62abfebcf0d2d5f",
  input:
    "0x6ea056a900000000000...",
  nonce: "0x5e4724",
  r: "0xd1556332df97e3bd911068651cfad6f975a30381f4ff3a55df7ab3512c78b9ec",
  s: "0x66b51cbb10cd1b2a09aaff137d9f6d4255bf73cb7702b666ebd5af502ffa4410",
  to: "0x4b9c25ca0224aef6a7522cabdbc3b2e125b7ca50",
  transactionIndex: "0x0",
  type: "0x0",
  v: "0x25",
  value: "0x0",
} */

eth_getUncleByBlockHashAndIndex

Returns information about a block's uncle by hash and uncle index.

Parameters​

Name
Type
Description

BlockHash

HexString<Hash>

Hash of the selected block.

UncleIndex

HexString<Number>

Uncle's index position.

Return Type​

UncleBlock | null - The block data or null if not found.

UncleBlock

type UncleBlock = {
  number: HexString<Number> | null; // Block number or null if block is pending.
  hash: HexString<Hash> | null; // Block hash or null if block is pending.
  parentHash: HexString<Hash>; // Hash of the parent block.
  nonce: HexString<Hash> | null; // Hash of the proof-of-work or null if block is pending.

  sha3Uncles: HexString<Hash>; // SHA3 hash of the uncles data in the block.
  logsBloom: HexString<FilterBloom> | null; // Bloom filter of the logs in the block or null if block is pending.
  transactionsRoot: HexString<Hash>; // Root hash of the transaction trie of the block.
  stateRoot: HexString<Hash>; // Root hash of the final state trie of the block.
  receiptsRoot: HexString<Hash>; // Root hash of the receipts trie of the block.

  miner: Address; // Miner's address for rewards.
  difficulty: HexString<Number>; // Difficulty for this block.
  totalDifficulty: HexString<Number>; // Total difficulty for the chain until this block.

  extraData: HexString; // 32-byte long space to preserve for the ethernity :]
  gasLimit: HexString<Number>; // Maximum gas allowed for this block.
  gasUsed: HexString<Number>; // Total gas used for all transactions in this block.

  size: HexString<Number>; // Size of this block in bytes.
  timestamp: HexString<Number>; // The unix timestamp for when the block was collated.

  uncles: HexString<Hash>[]; // Array of uncle hashes.
};

Example​

await provider.request({
  method: "eth_getUncleByBlockHashAndIndex",
  params: [
    "0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35",
    "0x0",
  ],
});
/* {
  difficulty: "0xbfabcdbd93dda",
  extraData: "0x737061726b706f6f6c2d636e2d6e6f64652d3132",
  gasLimit: "0x79f39e",
  gasUsed: "0x79ccd3",
  hash: "0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35",
  logsBloom:
    "0x4848112002a2020aaa081218004584...",
  miner: "0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c",
  nonce: "0x4db7a1c01d8a8072",
  number: "0x5bad55",
  parentHash:
    "0x61a8ad530a8a43e3583f8ec163f773ad370329b2375d66433eb82f005e1d6202",
  receiptsRoot:
    "0x5eced534b3d84d3d732ddbc714f5fd51d98a941b28182b6efe6df3a0fe90004b",
  sha3Uncles:
    "0x8a562e7634774d3e3a36698ac4915e37fc84a2cd0044cb84fa5d80263d2af4f6",
  size: "0x41c7",
  stateRoot:
    "0xf5208fffa2ba5a3f3a2f64ebd5ca3d098978bedd75f335f56b705d8715ee2305",
  timestamp: "0x5b541449",
  totalDifficulty: "0x12ac11391a2f3872fcd",
  transactionsRoot:
    "0xf98631e290e88f58a46b7032f025969039aa9b5696498efc76baf436fa69b262",
  uncles: []
} */

eth_signTypedData

Calculates an ethereum signature of the given typed structured data from the selected account.

Important

This method complies with the latest specification of EIP-712.

The document version used is commit 9e393a7.

Parameters​

Name
Type
Description

Account

Address

Account to sign from.

Data

MessagePayload | JSONString<MessagePayload>

Structured data to sign.

MessagePayload

// https://eips.ethereum.org/EIPS/eip-712#parameters
type MessagePayload = {
  domain: EIP712Domain;
  types: { EIP712Domain: EIP712Domain } & Record<string, TypedProperty[]>;
  primaryType: string;
  message: any;
};

// https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator
type EIP712Domain = {
  name?: string;
  version?: string;
  chainId?: Number<uint256>;
  verifyingContract?: Address;
  salt?: HexString<bytes32>;
};

// https://eips.ethereum.org/EIPS/eip-712#definition-of-typed-structured-data-%F0%9D%95%8A
type TypedProperty = {
  name: string;
  type: string;
};

Return Type​

HexString<Signature> - The ethereum ecdsa signature.

Example​

await provider.request({
  method: "eth_signTypedData",
  params: [
    "0x567d0382442c5178105fC03bd52b8Db6Afb4fE40",
    {
      types: {
        DeviceControl: [
          {
            name: "principal",
            type: "AuthorizedEntity",
          },
          {
            name: "emergency",
            type: "AuthorizedEntity",
          },
        ],
        AuthorizedEntity: [
          {
            name: "address",
            type: "address",
          },
          {
            name: "validUntil",
            type: "uint256",
          },
        ],
        EIP712Domain: [
          {
            name: "name",
            type: "string",
          },
          {
            name: "version",
            type: "string",
          },
          {
            name: "chainId",
            type: "uint256",
          },
          {
            name: "verifyingContract",
            type: "address",
          },
        ],
      },
      domain: {
        name: "Stargazer Demo",
        version: "1.0.0",
        chainId: "3",
        verifyingContract: "0xeb14c9bb6c2dec2ecb9b278c9fa1ec763b04d545",
      },
      primaryType: "DeviceControl",
      message: {
        principal: {
          address: "0xeb14c9bb6c2dec2ecb9b278c9fa1ec763b04d545",
          validUntil: "1657823568",
        },
        emergency: {
          address: "0xcac3da343670abb46bc6e8e6d375b66217519093",
          validUntil: "1752517998",
        },
      },
    },
  ],
});
// "0xa3f20717a250c2b0b729b7e5becbff67fdaef7e0699da4de7ca5895b02a170a12d887fd3b17bfdce3481f10bea41f45ba9f709d39ce8325427b57afcfc994cee1b"

eth_getUncleByBlockNumberAndIndex

Returns information about a block's uncle by number and uncle index.

Parameters​

Name
Type
Description

BlockNumber

HexString<Number>| "latest" | "earliest" | "pending"

Hexadecimal block number, or the string "latest", "earliest" or "pending".

UncleIndex

HexString<Number>

Uncle's index position.

Return Type​

UncleBlock | null - The block data or null if not found.

UncleBlock

type UncleBlock = {
  number: HexString<Number> | null; // Block number or null if block is pending.
  hash: HexString<Hash> | null; // Block hash or null if block is pending.
  parentHash: HexString<Hash>; // Hash of the parent block.
  nonce: HexString<Hash> | null; // Hash of the proof-of-work or null if block is pending.

  sha3Uncles: HexString<Hash>; // SHA3 hash of the uncles data in the block.
  logsBloom: HexString<FilterBloom> | null; // Bloom filter of the logs in the block or null if block is pending.
  transactionsRoot: HexString<Hash>; // Root hash of the transaction trie of the block.
  stateRoot: HexString<Hash>; // Root hash of the final state trie of the block.
  receiptsRoot: HexString<Hash>; // Root hash of the receipts trie of the block.

  miner: Address; // Miner's address for rewards.
  difficulty: HexString<Number>; // Difficulty for this block.
  totalDifficulty: HexString<Number>; // Total difficulty for the chain until this block.

  extraData: HexString; // 32-byte long space to preserve for the ethernity :]
  gasLimit: HexString<Number>; // Maximum gas allowed for this block.
  gasUsed: HexString<Number>; // Total gas used for all transactions in this block.

  size: HexString<Number>; // Size of this block in bytes.
  timestamp: HexString<Number>; // The unix timestamp for when the block was collated.

  uncles: HexString<Hash>[]; // Array of uncle hashes.
};

Example​

await provider.request({
  method: "eth_getUncleByBlockNumberAndIndex",
  params: ["0x29c", "0x0"],
});
/* {
  difficulty: "0xbfabcdbd93dda",
  extraData: "0x737061726b706f6f6c2d636e2d6e6f64652d3132",
  gasLimit: "0x79f39e",
  gasUsed: "0x79ccd3",
  hash: "0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35",
  logsBloom:
    "0x4848112002a2020aaa081218004584...",
  miner: "0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c",
  nonce: "0x4db7a1c01d8a8072",
  number: "0x5bad55",
  parentHash:
    "0x61a8ad530a8a43e3583f8ec163f773ad370329b2375d66433eb82f005e1d6202",
  receiptsRoot:
    "0x5eced534b3d84d3d732ddbc714f5fd51d98a941b28182b6efe6df3a0fe90004b",
  sha3Uncles:
    "0x8a562e7634774d3e3a36698ac4915e37fc84a2cd0044cb84fa5d80263d2af4f6",
  size: "0x41c7",
  stateRoot:
    "0xf5208fffa2ba5a3f3a2f64ebd5ca3d098978bedd75f335f56b705d8715ee2305",
  timestamp: "0x5b541449",
  totalDifficulty: "0x12ac11391a2f3872fcd",
  transactionsRoot:
    "0xf98631e290e88f58a46b7032f025969039aa9b5696498efc76baf436fa69b262",
  uncles: []
} */

eth_getFilterLogs

Returns associated logs of the given filter id. Node filters are created using eth_newFilter.

Parameters​

Name
Type
Description

FilterId

HexString<FilterId>

Filter id created using .

Return Type​

Log[] - Array of log objects found.

Log

type Log = {
  address: Address; // Address from which this log was generated.

  blockHash: HexString<Hash> | null; // Block hash from which this log was generated or null if transaction is pending.
  blockNumber: HexString<Number> | null; // Block number from which this log was generated or null if transaction is pending.

  transactionHash: HexString<Hash>; // Transaction hash from which this log was generated.
  transactionIndex: HexString<Number> | null; // Transaction index from which this log was generated or null if transaction is pending.

  data: HexString; // Data of non-indexed arguments for the log.
  logIndex: HexString<Number> | null; // Log index in the block or null if transaction is pending.
  removed: boolean; // True if the log was removed, due to a chain reorganization. False if it's a valid log.
  topics: HexString<Topic>[]; // Array of 0 - 4 topics.
};

Example​

await provider.request({
  method: "eth_getFilterLogs",
  params: ["0x10ff0bfbedb01f0dbd4106d14eb719ec38b6eb5b821c"],
});
/* [
  {
    address: "0xb5a5f22694352c15b00323844ad545abb2b11028",
    blockHash:
      "0x99e8663c7b6d8bba3c7627a17d774238eae3e793dee30008debb2699666657de",
    blockNumber: "0x5d12ab",
    data: "0x0000000000000000000000000000000000000000000000a247d7a2955b61d000",
    logIndex: "0x0",
    removed: false,
    topics: [
      "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
      "0x000000000000000000000000bdc0afe57b8e9468aa95396da2ab2063e595f37e",
      "0x0000000000000000000000007503e090dc2b64a88f034fb45e247cbd82b8741e",
    ],
    transactionHash:
      "0xa74c2432c9cf7dbb875a385a2411fd8f13ca9ec12216864b1a1ead3c99de99cd",
    transactionIndex: "0x3",
  },
  {
    address: "0xe38165c9f6deb144afc9c32c206b024817e1496d",
    blockHash:
      "0x99e8663c7b6d8bba3c7627a17d774238eae3e793dee30008debb2699666657de",
    blockNumber: "0x5d12ab",
    data: "0x0000000000000000000000000000000000000000000000000000000025c6b720",
    logIndex: "0x3",
    removed: false,
    topics: [
      "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
      "0x00000000000000000000000080e73e47173b2d00b531bf83bc39e710157125c3",
      "0x0000000000000000000000008f6cc93795969e5bbbf07c66dfee7d41ad24f1ef",
    ],
    transactionHash:
      "0x9e8f1cb1facb9a11a1cf947634053a0b2d557399f926b12127aa10497a2f0153",
    transactionIndex: "0x5",
  },
] */

eth_getBlockByNumber

Returns information about a block by number.

Parameters

Name
Type
Description

Return Type

Block | null - The block data or null if not found.

Block

Transaction

Example

dag_getMetagraphTransaction

Returns information about a transaction by hash and metagraph address. If the transaction object is returned, the transaction was included in a block and lives in the metagraph.

Parameters

Name
Type
Description

TransactionParams

Return Type

Transaction | null - Transaction object or null if not found.

Transaction

Proof

Example

eth_getTransactionByBlockHashAndIndex

Returns information about a transaction by block hash and transaction index position.

Parameters

Name
Type
Description

Return Type

Transaction | null - Transaction object or null if not found.

Transaction

Example

eth_newFilter

BlockNumber

HexString<Number>| "latest" | "earliest" | "pending"

Hexadecimal block number, or the string "latest", "earliest" or "pending".

ShowTransactionDetails

Boolean

If true returns the full transaction objects, otherwise the hashes of the transactions.

type Block = {
  number: HexString<Number> | null; // Block number or null if block is pending.
  hash: HexString<Hash> | null; // Block hash or null if block is pending.
  parentHash: HexString<Hash>; // Hash of the parent block.
  nonce: HexString<Hash> | null; // Hash of the proof-of-work or null if block is pending.

  sha3Uncles: HexString<Hash>; // SHA3 hash of the uncles data in the block.
  logsBloom: HexString<FilterBloom> | null; // Bloom filter of the logs in the block or null if block is pending.
  transactionsRoot: HexString<Hash>; // Root hash of the transaction trie of the block.
  stateRoot: HexString<Hash>; // Root hash of the final state trie of the block.
  receiptsRoot: HexString<Hash>; // Root hash of the receipts trie of the block.

  miner: Address; // Miner's address for rewards.
  difficulty: HexString<Number>; // Difficulty for this block.
  totalDifficulty: HexString<Number>; // Total difficulty for the chain until this block.

  extraData: HexString; // 32-byte long space to preserve for the ethernity :]
  gasLimit: HexString<Number>; // Maximum gas allowed for this block.
  gasUsed: HexString<Number>; // Total gas used for all transactions in this block.

  size: HexString<Number>; // Size of this block in bytes.
  timestamp: HexString<Number>; // The unix timestamp for when the block was collated.

  transactions: Transaction[] | HexString<Hash>[]; // Array of transaction objects or transaction hashes.

  uncles: HexString<Hash>[]; // Array of uncle hashes.
};
type Transaction = {
  hash: HexString<Hash>; // Hash of the transaction.
  from: Address; // Address of the sender.
  to: Address | null; // Address of the receiver or null for contract creations.
  value: HexString<Number>; // Value sent in WEI.

  blockHash: HexString<Hash> | null; // Block hash of transaction or null if transaction is pending.
  blockNumber: HexString<Number> | null; // Block number of transaction or null if transaction is pending.
  nonce: HexString<Number>; // Number of transactions made by the sender before.

  gas: HexString<Number>; // Gas units provider by the sender.
  gasPrice: HexString<Number>; // Gas price provider by the sender in WEI.
  maxFeePerGas?: HexString<Number>; // Maximum fee in WEI per gas unit. EIP-1559.
  maxPriorityFeePerGas?: HexString<Number>; // Maximum fee in WEI per gas unit above the base fee. EIP-1559.

  input: HexString; // Data sent with the transaction.

  r: HexString; // ECDSA signature r.
  s: HexString; // ECDSA signature s.
  v: HexString; // ECDSA recovery ID.

  transactionIndex: HexString<Number> | null; // Transaction index in block or null if transaction is pending.
  type: HexString<Number>; // Transaction type
};ty
await provider.request({
  method: "eth_getBlockByNumber",
  params: [
    "0x5bad55",
  ],
});
/* {
  difficulty: "0xbfabcdbd93dda",
  extraData: "0x737061726b706f6f6c2d636e2d6e6f64652d3132",
  gasLimit: "0x79f39e",
  gasUsed: "0x79ccd3",
  hash: "0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35",
  logsBloom:
    "0x4848112002a2020aaa081218004584...",
  miner: "0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c",
  nonce: "0x4db7a1c01d8a8072",
  number: "0x5bad55",
  parentHash:
    "0x61a8ad530a8a43e3583f8ec163f773ad370329b2375d66433eb82f005e1d6202",
  receiptsRoot:
    "0x5eced534b3d84d3d732ddbc714f5fd51d98a941b28182b6efe6df3a0fe90004b",
  sha3Uncles:
    "0x8a562e7634774d3e3a36698ac4915e37fc84a2cd0044cb84fa5d80263d2af4f6",
  size: "0x41c7",
  stateRoot:
    "0xf5208fffa2ba5a3f3a2f64ebd5ca3d098978bedd75f335f56b705d8715ee2305",
  timestamp: "0x5b541449",
  totalDifficulty: "0x12ac11391a2f3872fcd",
  transactions: [
    "0x8784d99762bccd03b2086eabccee0d77f14d05463281e121a62abfebcf0d2d5f",
    "0x311be6a9b58748717ac0f70eb801d29973661aaf1365960d159e4ec4f4aa2d7f",
    "0xe42b0256058b7cad8a14b136a0364acda0b4c36f5b02dea7e69bfd82cef252a2",
    "0x4eb05376055c6456ed883fc843bc43df1dcf739c321ba431d518aecd7f98ca11",
    "0x994dd9e72b212b7dc5fd0466ab75adf7d391cf4f206a65b7ad2a1fd032bb06d7",
    ...
  ],
  transactionsRoot:
    "0xf98631e290e88f58a46b7032f025969039aa9b5696498efc76baf436fa69b262",
  uncles: [
    "0x824cce7c7c2ec6874b9fa9a9a898eb5f27cbaf3991dfa81084c3af60d1db618c",
  ],
} */
​
​
​

Data

Object<TransactionParams>

Transaction info object

type TransactionParams = {
  metagraphAddress: String; // Metagraph address
  hash: String; // Hash of the transaction
};
type Transaction = {
  hash: String<Hash>; // Hash of the transaction
  amount: Number; // Amount sent
  source: Address; // Address of the sender
  destination: Address; // Address of the receiver
  fee: Number; // Fee sent
  parent: {
    hash: String<Hash>; // Hash of the parent transaction
    ordinal: Number; // Ordinal of the parent transaction
  };
  blockHash: String<Hash>; // Hash of the block
  snapshotHash: String<Hash>; // Hash of the snapshot
  snapshotOrdinal: Number; // Ordinal of the snapshot
  transactionOriginal: {
    value: {
      source: Address; // Address of the sender
      destination: Address; // Address of the receiver
      amount: Number; // Amount sent
      fee: Number; // Fee sent
      parent: {
        hash: String<Hash>; // Hash of the parent transaction
        ordinal: Number; // Ordinal of the parent transaction
      };
      salt: BigNumber | String; // Salt
    };
    proofs: Proof[]; // Proofs
  };
  timestamp: String; // Timestamp
};
type Proof = {
  id: String; // Id of the signature
  signature: String; // Signature
};
await provider.request({
  method: "dag_getMetagraphTransaction",
  params: [
    {
      metagraphAddress: "DAG0KheCYqEmFoQEWdFwrZGaXabJsWJyUvjpsLjE",
      hash: "233af0219d6a956aae0839c18ce95470dc2ac0645aa3135a22be608c06e7713e",
    },
  ],
});

// {
//     "hash": "233af0219d6a956aae0839c18ce95470dc2ac0645aa3135a22be608c06e7713e",
//     "amount": 300000000,
//     "source": "DAG77zerQ2BUVhtVgkmseihkEfLXieBBm57vqA4J",
//     "destination": "DAG2fMnbEmsWhgYGhvdREVELyESKUqGNTEWf4B61",
//     "fee": 0,
//     "parent": {
//         "hash": "9ef0cd77c91abe5dac643f0ada9e51af20a30c38b2b2cf7b8793a5955d5c9485",
//         "ordinal": 4
//     },
//     "blockHash": "dad7482866af8d9f44c2b309d263add3b4c2c8e6063a36910783a42fe2bd5509",
//     "snapshotHash": "d22a21946e0b257a489212b30a593274798892be2ef6a02b8d8218abc8a5f0ae",
//     "snapshotOrdinal": 34233,
//     "transactionOriginal": {
//         "value": {
//             "source": "DAG77zerQ2BUVhtVgkmseihkEfLXieBBm57vqA4J",
//             "destination": "DAG2fMnbEmsWhgYGhvdREVELyESKUqGNTEWf4B61",
//             "amount": 300000000,
//             "fee": 0,
//             "parent": {
//                 "ordinal": 4,
//                 "hash": "9ef0cd77c91abe5dac643f0ada9e51af20a30c38b2b2cf7b8793a5955d5c9485"
//             },
//             "salt": 8792229999094409
//         },
//         "proofs": [
//             {
//                 "id": "b85cbc0d210bfb98de58b9b1c6d195f6ee09e254e489f284756e3ebae82054823b04e64bcc62bb6b20ee8016b819419389037d8d09e278e47fe79645cfd8b166",
//                 "signature": "30450221009a66b5a64998df405c40e5eb6b4ad42e3e4f7b31d70071e866c045ef58dc1f9b022048a66d373e241bc10f917f11832eccf6244b255c68c11c6ee1e7f442068ae613"
//             }
//         ]
//     },
//     "timestamp": "2023-06-29T18:38:00.412Z"
// }
​
​
​

BlockHash

HexString<Hash>

Hash of the selected block.

Index

HexString<Number>

Transaction index.

type Transaction = {
  hash: HexString<Hash>; // Hash of the transaction.
  from: Address; // Address of the sender.
  to: Address | null; // Address of the receiver or null for contract creations.
  value: HexString<Number>; // Value sent in WEI.

  blockHash: HexString<Hash> | null; // Block hash of transaction or null if transaction is pending.
  blockNumber: HexString<Number> | null; // Block number of transaction or null if transaction is pending.
  nonce: HexString<Number>; // Number of transactions made by the sender before.

  gas: HexString<Number>; // Gas units provider by the sender.
  gasPrice: HexString<Number>; // Gas price provider by the sender in WEI.
  maxFeePerGas?: HexString<Number>; // Maximum fee in WEI per gas unit. EIP-1559.
  maxPriorityFeePerGas?: HexString<Number>; // Maximum fee in WEI per gas unit above the base fee. EIP-1559.

  input: HexString; // Data sent with the transaction.

  r: HexString; // ECDSA signature r.
  s: HexString; // ECDSA signature s.
  v: HexString; // ECDSA recovery ID.

  transactionIndex: HexString<Number> | null; // Transaction index in block or null if transaction is pending.
  type: HexString<Number>; // Transaction type
};
await provider.request({
  method: "eth_getTransactionByBlockHashAndIndex",
  params: [
    "0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35",
    "0x0",
  ],
});

/* {
  blockHash:
    "0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35",
  blockNumber: "0x5bad55",
  from: "0xfbb1b73c4f0bda4f67dca266ce6ef42f520fbb98",
  gas: "0x249f0",
  gasPrice: "0x174876e800",
  hash: "0x8784d99762bccd03b2086eabccee0d77f14d05463281e121a62abfebcf0d2d5f",
  input:
    "0x6ea056a900000000000...",
  nonce: "0x5e4724",
  r: "0xd1556332df97e3bd911068651cfad6f975a30381f4ff3a55df7ab3512c78b9ec",
  s: "0x66b51cbb10cd1b2a09aaff137d9f6d4255bf73cb7702b666ebd5af502ffa4410",
  to: "0x4b9c25ca0224aef6a7522cabdbc3b2e125b7ca50",
  transactionIndex: "0x0",
  type: "0x0",
  v: "0x25",
  value: "0x0",
} */
​
​
​

eth_getBlockByHash

eth_getBlockByHash

Returns information about a block by hash.

Parameters​

Name
Type
Description

BlockHash

HexString<Hash>

Hash of the selected block.

ShowTransactionDetails

Boolean

If true returns the full transaction objects, otherwise the hashes of the transactions.

Return Type​

Block | null - The block data or null if not found.

Block

type Block = {
  number: HexString<Number> | null; // Block number or null if block is pending.
  hash: HexString<Hash> | null; // Block hash or null if block is pending.
  parentHash: HexString<Hash>; // Hash of the parent block.
  nonce: HexString<Hash> | null; // Hash of the proof-of-work or null if block is pending.

  sha3Uncles: HexString<Hash>; // SHA3 hash of the uncles data in the block.
  logsBloom: HexString<FilterBloom> | null; // Bloom filter of the logs in the block or null if block is pending.
  transactionsRoot: HexString<Hash>; // Root hash of the transaction trie of the block.
  stateRoot: HexString<Hash>; // Root hash of the final state trie of the block.
  receiptsRoot: HexString<Hash>; // Root hash of the receipts trie of the block.

  miner: Address; // Miner's address for rewards.
  difficulty: HexString<Number>; // Difficulty for this block.
  totalDifficulty: HexString<Number>; // Total difficulty for the chain until this block.

  extraData: HexString; // 32-byte long space to preserve for the ethernity :]
  gasLimit: HexString<Number>; // Maximum gas allowed for this block.
  gasUsed: HexString<Number>; // Total gas used for all transactions in this block.

  size: HexString<Number>; // Size of this block in bytes.
  timestamp: HexString<Number>; // The unix timestamp for when the block was collated.

  transactions: Transaction[] | HexString<Hash>[]; // Array of transaction objects or transaction hashes.

  uncles: HexString<Hash>[]; // Array of uncle hashes.
};

Transaction

type Transaction = {
  hash: HexString<Hash>; // Hash of the transaction.
  from: Address; // Address of the sender.
  to: Address | null; // Address of the receiver or null for contract creations.
  value: HexString<Number>; // Value sent in WEI.

  blockHash: HexString<Hash> | null; // Block hash of transaction or null if transaction is pending.
  blockNumber: HexString<Number> | null; // Block number of transaction or null if transaction is pending.
  nonce: HexString<Number>; // Number of transactions made by the sender before.

  gas: HexString<Number>; // Gas units provider by the sender.
  gasPrice: HexString<Number>; // Gas price provider by the sender in WEI.
  maxFeePerGas?: HexString<Number>; // Maximum fee in WEI per gas unit. EIP-1559.
  maxPriorityFeePerGas?: HexString<Number>; // Maximum fee in WEI per gas unit above the base fee. EIP-1559.

  input: HexString; // Data sent with the transaction.

  r: HexString; // ECDSA signature r.
  s: HexString; // ECDSA signature s.
  v: HexString; // ECDSA recovery ID.

  transactionIndex: HexString<Number> | null; // Transaction index in block or null if transaction is pending.
  type: HexString<Number>; // Transaction type
};

Example​

await provider.request({
  method: "eth_getBlockByHash",
  params: ["0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35"],
});
/* {
  difficulty: "0xbfabcdbd93dda",
  extraData: "0x737061726b706f6f6c2d636e2d6e6f64652d3132",
  gasLimit: "0x79f39e",
  gasUsed: "0x79ccd3",
  hash: "0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35",
  logsBloom:
    "0x4848112002a2020aaa081218004584...",
  miner: "0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c",
  nonce: "0x4db7a1c01d8a8072",
  number: "0x5bad55",
  parentHash:
    "0x61a8ad530a8a43e3583f8ec163f773ad370329b2375d66433eb82f005e1d6202",
  receiptsRoot:
    "0x5eced534b3d84d3d732ddbc714f5fd51d98a941b28182b6efe6df3a0fe90004b",
  sha3Uncles:
    "0x8a562e7634774d3e3a36698ac4915e37fc84a2cd0044cb84fa5d80263d2af4f6",
  size: "0x41c7",
  stateRoot:
    "0xf5208fffa2ba5a3f3a2f64ebd5ca3d098978bedd75f335f56b705d8715ee2305",
  timestamp: "0x5b541449",
  totalDifficulty: "0x12ac11391a2f3872fcd",
  transactions: [
    "0x8784d99762bccd03b2086eabccee0d77f14d05463281e121a62abfebcf0d2d5f",
    "0x311be6a9b58748717ac0f70eb801d29973661aaf1365960d159e4ec4f4aa2d7f",
    "0xe42b0256058b7cad8a14b136a0364acda0b4c36f5b02dea7e69bfd82cef252a2",
    "0x4eb05376055c6456ed883fc843bc43df1dcf739c321ba431d518aecd7f98ca11",
    "0x994dd9e72b212b7dc5fd0466ab75adf7d391cf4f206a65b7ad2a1fd032bb06d7",
    ...
  ],
  transactionsRoot:
    "0xf98631e290e88f58a46b7032f025969039aa9b5696498efc76baf436fa69b262",
  uncles: [
    "0x824cce7c7c2ec6874b9fa9a9a898eb5f27cbaf3991dfa81084c3af60d1db618c",
  ],
} */

Supported Connectors

This section provides guidance on integrating different library connectors to facilitate wallet connectivity in your application. We support connectors for , , and . Each connector has its own set of configurations/features and is designed to simplify the process of connecting to the Stargazer Wallet.

Web3React

is a framework that allows you to interact with Ethereum blockchain and smart contracts. It provides a simple and flexible way to connect to different wallets.

Installation

To install the connector, run the following command:

If you're using NPM

If you're using NPM

Example Usage

Wagmi

is a set of React Hooks for Ethereum, which simplifies the process of connecting to Ethereum networks and smart contracts.

Installation

To install the connector, run the following command:

If you're using NPM

If you're using NPM

Example Usage

React Hooks

The connector is a generic react hook that will enable your app to connect to the stargazer wallet on the constellation network, it will return a EIP-1193 compatible provider (among other properties), that will only connect to the constellation network (DAG) via RPC requests, the constellation RPC API reference can be found .

Installation

To install the connector, run the following command:

If you're using NPM

If you're using NPM

Example Usage

New Connectors Support

We are committed to expanding our support for library connectors to meet the evolving needs of our users. If you require a connector that is not currently supported, or have suggestions for new connectors, we are open to exploring these possibilities and integrating them into the wallet.

Requesting New Connectors

To request the addition of new library connectors or suggest improvements, please reach out to us through the following channels:

  • GitHub Issues:

  • Discord Channel:

npm install @stardust-collective/web3-react-stargazer-connector
yarn add @stardust-collective/web3-react-stargazer-connector
import { StargazerWeb3ReactConnector } from "@stardust-collective/web3-react-stargazer-connector";
import { useWeb3React } from "@web3-react/core";

const stargazerConnector = new StargazerWeb3ReactConnector({
  supportedChainIds: [1, 3],
});

function App() {
  const { activate, active } = useWeb3React();

  const connect = async () => {
    try {
      await activate(stargazerConnector);
    } catch (ex) {
      console.error(ex);
    }
  };

  return (
    <div>
      <button onClick={connect}>{active ? "Connected" : "Connect"}</button>
    </div>
  );
}

export default App;
npm install @stardust-collective/web3-react-stargazer-connector
yarn add @stardust-collective/web3-react-stargazer-connector
import {stargazerWalletWagmiConnector} from '@stardust-collective/web3-react-stargazer-connector';
import { mainnet, polygon } from 'wagmi/chains'
import { createConfig, http, useConnect } from 'wagmi'

const stargazerConnector = stargazerWalletWagmiConnector();

declare module 'wagmi' {
  interface Register {
    config: typeof config
  }
}

const config = createConfig({
  chains: [mainnet, polygon],
  transports: {
    [mainnet.id]: http('[your rpc endpoint url]'),
    [polygon.id]: http('[your rpc endpoint url]'),
  },
  connectors: [
    stargazerWalletWagmiConnector({}),
    ...other wallet connectors
  ],
})

function App() {
  const { connectors, connect } = useConnect()
  const { address } = useAccount();

  const doConnect = () => {
    for(const connector of connectors){
      if(connector.type === stargazerWalletWagmiConnector.type){
        connect(connector);
      }
    }
  }

  return (
    <div>
      <button onClick={doConnect}>Connect Wallet</button>
      {address && <p>Connected as {address}</p>}
    </div>
  );
}

export default App;
npm install @stardust-collective/web3-react-stargazer-connector
yarn add @stardust-collective/web3-react-stargazer-connector
import {useStargazerWallet} from '@stardust-collective/web3-react-stargazer-connector';

function App() {
  const {activate, deactivate, ...state } = useStargazerWallet();

  const doConnect = async () => {
    await activate();
  };

  const doSignMessage = async () => {
    if(!state.active){
      return;
    }

    const signatureRequest = {
      content: 'Sign this message to confirm your participation in this project.',
      metadata: {
        field1: 'an-useful-value',
        field2: 1,
        field3: null /* ,
        field4: {
          // Nested fields are not supported
          prop:1
        } */
      }
    };

    // Encode the signature request - Base64 < JSON < Request
    const signatureRequestEnconded = window.btoa(JSON.stringify(signatureRequest));

    await state.request({
      method: 'dag_signMessage',
      params: [state.account, signatureRequestEnconded]
    });
  }

  return (
    <div>
      <span>Connected To: {state.active && state.account}</span>
      <button onClick={doConnect}>{state.active ? "Connected" : "Connect"}</button>
      <button onClick={doSignMessage}>Sign Message</button>
    </div>
  );
}

export default App;
web3react/v6
wagmi
react hooks
​
web3react/v6
​
web3react/v6
​
​
wagmi
​
wagmi
​
​
react hooks
here
​
react hooks
​
​
​
StardustCollective/stargazer-wallet-connector
Constellation Discord

Sending RPC Requests

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 Provider Activation, 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 dag_accounts RPC method and eth_accounts 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 dag_accounts RPC method and eth_accounts RPC method.

Send an ETH contract call​

For interaction with ethereum smart contracts you can use the eth_call RPC method and the eth_sendTransaction RPC method, respectively for read and write operations. In the following example we will be using the ethers package, and a demo contract from the Stargazer Demos. The ethers 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.

Important

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

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

Send an ETH read call​

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

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!"

Send an ETH contract write call​

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

Important

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

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

Send ETH Transactions​

As the ethereum chain reveals the eth_sendTransaction 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 Contract instance, and therefore an ethers Web3Provider. In the background the ethers package will call eth_sendTransaction for us.

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

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 Contract instance, and therefore an ethers Web3Provider. In the background the ethers package will call eth_sendTransaction for us.

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

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 Web3Provider and an ethers Signer. In the background the ethers package will call eth_sendTransaction for us.

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

Ethereum RPC API

Signing Data

Signing arbitrary data enables you to verify the user's possession of an account. This guide will walk you through the signing process and verification.

Obtain a chain provider

As covered in , obtain a chain provider for the networks you want to interact with. In the following examples, we will use both Ethereum and Constellation providers.

Constellation Message Signing

Build a signature request

Constellation signatures for messages are done through a . The signature request object is sent for the user to accept. Uppon approval, a signature of the whole object is returned.

Encode the signature request

Requests need to be a Base64 < JSON encoded string to sign. The wallet will then generate the signature from the same characters that compose this encoded request.

Send the signature request

Once built and encoded, you can send the encoded signature request using the RPC method.

Important

When the signature request is sent, the wallet will verify compliance with the schema of the . If it does not comply, the wallet will throw an error.

The returned signature corresponds to the SHA512 hash of the encoded signature request and the private key of the user. ECDSA.sign(privateKey, sha512(signatureRequestEnconded)).

Read more about

Get the account public key

After you generate a signature from your encoded request, you need to retrieve the public key from the signer's account for future verification. This is due to the fact that Constellation signatures are not recoverable (i.e. do not contain the v parameter like in Ethereum).

Ethereum Message Signing

The Stargazer Ethereum RPC API implements both () and () as arbitrary message signing methods.

personal_sign method

The RPC API provided reveals the RPC method for message signing. In this case, the message signed is an arbitrary hex string prefixed by the "\x19Ethereum Signed Message:\n" string and the length of the message in bytes from .

The returned signature corresponds to the keccak256 hash of the prefix + message string and the private key of the user. ECDSA.sign(privateKey, keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)).

Read more about

eth_signTypedData method

The RPC API provided reveals the RPC method for typed message signing. In this case, the message signed is the hash of the typed data according to prefixed by the "\x19\x01" string according to .

The returned signature corresponds to the keccak256 hash of the domainSeparator + hashStruct(message) and the private key of the user. ECDSA.sign(privateKey, keccak256("\x19\x01" + domainSeparator + hashStruct(message)).

Read more about

Constellation Signature Verification

For signature verification, we will be using the package. The following snippet illustrates how you can verify an encoded request signature.

Ethereum Signature Verification

For signature verification, we will be using the package. The following snippets illustrate how you can verify different message signatures.

eth_personalSign

eth_signTypedData

const dagProvider = window.stargazer.getProvider("constellation");
const ethProvider = window.stargazer.getProvider("ethereum");
// Build the signature request
const signatureRequest: SignatureRequest = {
  content: "Sign this message to confirm your address",
  metadata: {
    user: "3feb69d6-d3f0-4812-9c93-384bee08afe8",
  },
};
// Encode the signature request - Base64 < JSON < Request
const signatureRequestEnconded = window.btoa(JSON.stringify(signatureRequest));
// Send the request and wait for the signature
await dagProvider.request({
  method: "dag_signMessage",
  params: [
    "DAG88C9WDSKH451sisyEP3hAkgCKn5DN72fuwjfX",
    signatureRequestEnconded,
  ],
});
// "3045022100b35798008516373fcc6eef75fe8e322ce8fe0dccc4802b052f3ddc7c6b5dc2900220154cac1e4f3e7d9a64f4ed9d2a518221b273fe782f037a5842725054f1c62280"
// Send the request and wait for the signature
await dagProvider.request({
  method: "dag_getPublicKey",
  params: ["DAG88C9WDSKH451sisyEP3hAkgCKn5DN72fuwjfX"],
});
// "0482c4566a9c4cbb6f23b9a31c96876501c71f5c04b35f416e0b2243113cce8fb386a2db0b3881d1c908d33465748b948649165a6705904120238999eed6eed1f4"
// Send the request and wait for the signature
await dagProvider.request({
  method: "personal_sign",
  params: [
    "0x5369676e2074686973206d65737361676520746f20636f6e6669726d20796f7572206164647265737320616e64207573657249642033666562363964362d643366302d343831322d396339332d333834626565303861666538",
    "0x9b2055d370f73ec7d8a03e965129118dc8f5bf83",
  ],
});
// "0xa3f20717a250c2b0b729b7e5becbff67fdaef7e0699da4de7ca5895b02a170a12d887fd3b17bfdce3481f10bea41f45ba9f709d39ce8325427b57afcfc994cee1b"

// Can also be a valid UTF-8 string
await dagProvider.request({
  method: "personal_sign",
  params: [
    "Sign this message to confirm your address and userId 3feb69d6-d3f0-4812-9c93-384bee08afe8",
    "0x9b2055d370f73ec7d8a03e965129118dc8f5bf83",
  ],
});
// "0xa3f20717a250c2b0b729b7e5becbff67fdaef7e0699da4de7ca5895b02a170a12d887fd3b17bfdce3481f10bea41f45ba9f709d39ce8325427b57afcfc994cee1b"
await provider.request({
  method: "eth_signTypedData",
  params: [
    "0x567d0382442c5178105fC03bd52b8Db6Afb4fE40",
    {
      types: {
        DeviceControl: [
          {
            name: "principal",
            type: "AuthorizedEntity",
          },
          {
            name: "emergency",
            type: "AuthorizedEntity",
          },
        ],
        AuthorizedEntity: [
          {
            name: "address",
            type: "address",
          },
          {
            name: "validUntil",
            type: "uint256",
          },
        ],
        EIP712Domain: [
          {
            name: "name",
            type: "string",
          },
          {
            name: "version",
            type: "string",
          },
          {
            name: "chainId",
            type: "uint256",
          },
          {
            name: "verifyingContract",
            type: "address",
          },
        ],
      },
      domain: {
        name: "Stargazer Demo",
        version: "1.0.0",
        chainId: "3",
        verifyingContract: "0xeb14c9bb6c2dec2ecb9b278c9fa1ec763b04d545",
      },
      primaryType: "DeviceControl",
      message: {
        principal: {
          address: "0xeb14c9bb6c2dec2ecb9b278c9fa1ec763b04d545",
          validUntil: "1657823568",
        },
        emergency: {
          address: "0xcac3da343670abb46bc6e8e6d375b66217519093",
          validUntil: "1752517998",
        },
      },
    },
  ],
});
// "0xa3f20717a250c2b0b729b7e5becbff67fdaef7e0699da4de7ca5895b02a170a12d887fd3b17bfdce3481f10bea41f45ba9f709d39ce8325427b57afcfc994cee1b"
import { dag4 } from "@stardust-collective/dag4";

const publicKey = "account-public-key";
const signatureRequestEnconded = "the-base64-encoded-signature-request";
const signatureHex = "some-hex-encoded-signature";

const valid: boolean = dag4.keyStore.verify(
  publicKey,
  signatureRequestEnconded,
  signatureHex
);

const publicKeyAddress = dag4.keyStore.getDagAddressFromPublicKey(publicKey);
import * as ethers from "ethers";

const accountWhichSigned = "0x9b2055d370f73ec7d8a03e965129118dc8f5bf83";
const messageSigned = "some-message-the-user-signed";
const signatureHex = "some-hex-encoded-signature";

const messageHash = ethers.utils.hashMessage(messageSigned);
const recoveredAddress = ethers.utils.recoverAddress(messageHash, signatureHex);

if (recoveredAddress !== accountWhichSigned) {
  throw new Error("Signature is not valid");
}
import * as ethers from "ethers";

const accountWhichSigned = "0x9b2055d370f73ec7d8a03e965129118dc8f5bf83";
const messageSigned = {
  // The EIP-712 domain signed
  domain: {
    name: "Stargazer Demo",
    version: "1.0.0",
    chainId: 3,
    verifyingContract: "0xabcdefABCDEF1234567890abcdefABCDEF123456",
  },
  // The EIP-712 types signed
  types: {
    DeviceControl: [
      { name: "principal", type: "AuthorizedEntity" },
      { name: "emergency", type: "AuthorizedEntity" },
    ],
    AuthorizedEntity: [
      { name: "address", type: "address" },
      { name: "validUntil", type: "uint256" },
    ],
  },
  // The EIP-712 message signed
  value: {
    principal: {
      address: "0xEb14c9bb6C2DEc2eCb9B278C9fa1EC763B04d545",
      validUntil: 1657823568,
    },
    emergency: {
      address: "0xcAc3DA343670aBB46BC6E8e6d375B66217519093",
      validUntil: 1752517998,
    },
  },
};
const signatureHex = "some-hex-encoded-signature";

const messageHash = ethers.utils._TypedDataEncoder.hash(
  messageSigned.domain,
  messageSigned.types,
  messageSigned.value
);
const recoveredAddress = ethers.utils.recoverAddress(messageHash, signatureHex);

if (recoveredAddress !== accountWhichSigned) {
  throw new Error("Signature is not valid");
}
Provider Activation
​
​
signature request object
​
​
dag_signMessage
signature request object
Constellation signature verification
​
​
EIP-191
personal_sign
EIP-712
eth_signTypedData
​
personal_sign
EIP-191
Ethereum signature verification
​
eth_signTypedData
EIP-712
EIP-191
Ethereum signature verification
​
@stardust-collective/dag4
​
ethers

eth_chainId

Returns the current network id.

Parameters​

None

Return Type​

ChainId - The current network id. The full list of chain IDs is available at chainlist.org. Some of the common ones are noted bellow.

ChainId

type ChainId =
  | "1" // Ethereum Mainnet
  | "2" // Morden TestNet (deprecated)
  | "3" // Ropsten TestNet
  | "4" // Rinkeby TestNet
  | "5" // Goerli TestNet
  | "11155111"; // Sepolia TestNet

Example​

await provider.request({ method: "net_version", params: [] });
// "3"

dag_chainId

Returns the current network id.

Parameters

None

Return Type

ChainId - The current network id.

ChainId

type ChainId =
  | "1" // Constellation MainNet
  | "3"; // Ceres Testnet (fka. Exchanges Network)

Example

await provider.request({ method: "dag_chainId", params: [] });
// "3"