Graphite
  • Overview
    • Introduction
    • What is Graphite?
    • Connect to Graphite
    • Graphite account activation
    • Graphite Wrapped Tokens
  • Build on Graphite
    • Getting started
    • System Contracts
      • Account Activation
      • Filter Contract (KYC Transaction Filters)
      • KYC Contract
      • Reputation
    • How to Complete KYC in a Testnet
    • How to Deploy Smart Contracts Using Hardhat: A Step-by-Step Guide
    • SDK
      • JS SDK
  • Infrastructure
    • Graphite Nodes
      • Graphite testnet node setup
      • Graphite mainnet node setup
  • Ecosystem
    • Graphite Wallet
      • Graphite Web3 Documentation
    • Graphite Bridge
    • The Graphite Explorer
      • API documentation
    • Faucet Testnet
Powered by GitBook
On this page
  • Basic Usage
  • Available methods
  • graphite.enable(): Promise<string>
  • graphite.isEnabled(): Promise<bool>
  • graphite.request(): Promise<Object>
  • graphite.getBalance(): Promise<number>
  • graphite.getAddress(): Promise<string>
  • graphite.getAccountInfo(): Promise<object>
  • graphite.sendTx(params): Promise<string>
  • graphite.activateAccount(): Promise<string>
  • graphite.updateKycLevel(level): Promise<string>
  • graphite.updateKycFilter(filter): Promise<string>
  • graphite.getLastKycRequest(): Promise<Object>
  • graphite.getActiveNetwork(): Promise<"mainnet" | "testnet">
  • graphite.changeActiveNetwork(network: "mainnet" | "testnet"): Promise<"mainnet" | "testnet">
  1. Ecosystem
  2. Graphite Wallet

Graphite Web3 Documentation

Basic Usage

  • Detect the provider (window.graphite)

  • Call the window.graphite.enable() method

  • If access is granted, use the available api

Available methods

graphite.enable(): Promise<string>

Calling this method triggers a user interface that allows a user to approve or reject account access for a given dApp. This method returns a Promise that is resolved with an account if the user approves access or is rejected with an Error if the user rejects access.

await window.graphite.enable()
// If success:
// => 0xca8a66887dfbEf870a2d96de536986516a37fa12

// If regected:
// throw Error {
//  "code": -1,
//  "message": "User rejected the request."
//}

graphite.isEnabled(): Promise<bool>

Returns true if the dApp is already connected to a user's wallet, or if requesting access would return true without user confirmation (e.g. the dApp is whitelisted), and false otherwise.

await window.graphite.isEnabled()
// => true

graphite.request(): Promise<Object>

JSON-RPC request to interact with the Graphite node.

await window.graphite.request({
  "jsonrpc":"2.0",
  "method":"eth_getBalance",
  "params": ["0x1D9f2C01c8A20DcC59e806caFF5f46033e84ad2B", "latest"],
  "id":1
})
// => {
//    "jsonrpc": "2.0",
//    "id": 1,
//    "result": "0x6e9ce78211603c34113800"
// }

graphite.getBalance(): Promise<number>

JSON-RPC request to interact with the Graphite node.

const balance = await window.graphite.getBalance()
// balance => 1094658474000000000

graphite.getAddress(): Promise<string>

Returns the active account.

const account = await window.graphite.getAddress()
// account => '0xca8a66887dfbEf870a2d96de536986516a37fa12'

graphite.getAccountInfo(): Promise<object>

Returns basic account information, such as balance, activation status, KYC level and KYC filter.

const info = await window.graphite.getAccountInfo()
// info => {
//    "balance": "0xf31021515242400",
//    "active": true,
//    "kycLevel": "1",
//    "kycFilterLevel": "2"
//    "reputation": "255"
//  }

graphite.sendTx(params): Promise<string>

To send a transaction, use the sendTx method where params is a options object. The wallet should ask the user for permission, and if given, try to sign and send transactions. This returns the transaction hash, if the transaction was submitted successfully, otherwise throws an error.

const account = await window.graphite.getAddress()
const nonce = await window.graphite.request({
  "jsonrpc":"2.0",
  "method":"eth_getTransactionCount",
  "params": [account, "latest"],
  "id":1
})
const params = {
  nonce,
  from: account,
  to: '0x3526e99937B60E2CC18f10f6262B4D320FD2E371',
  value: '1000000000000',
  gasPrice: '18000000000',
  gas: '22000'
}
let hash = await window.graphite.sendTx(params)
// => '0x42d340b0e52ae61f0e004bd1939a3a8d23f02e6e09daf0ed402817948273e9ce'

graphite.activateAccount(): Promise<string>

To send transactions on Graphite, a user needs to activate their account. This can be done using the method activateAccount. The wallet should ask the user for permission to activate. This returns the transaction hash, if the transaction was submitted successfully, otherwise throws an error. The account balance must be non-zero.

const hash = window.graphite.activateAccount()
// => {
// hash: '0x42d340b0e52ae61f0e004bd1939a3a8d23f02e6e09daf0ed402817948273e9ce',
// data: '0x1b9265b8'
// }

graphite.updateKycLevel(level): Promise<string>

To change the KYC level, use the method updateKycLevel. The wallet should ask the user for permission to change the level. Returns the transaction hash, if transaction was submitted successfully, otherwise throws an error. The account must already be activated and have a non-zero balance. The parameter level can be from 1 to 3.

const hash = window.graphite.updateKycLevel(1)
// => {
// hash: '0x42d340b0e52ae61f0e004bd1939a3a8d23f02e6e09daf0ed402817948273e9ce',
// uuid: 'd1c2b8a9-2976-4615-b7f4-2aca95a50123',
// data: '0x1a7106730000000000000000000000000000000000000000000000000000000000000001e8f2c758111c95c39485e683ad7f24c53c0aca399c0edea39532bda5e2b95c11'
// }

graphite.updateKycFilter(filter): Promise<string>

To change the KYC filter, use the method updateKycFilter. The wallet should ask the user for permission to change the filter. Returns the transaction hash, if transaction was submitted successfully, otherwise throws an error. The account must already be activated and have a non-zero balance. The parameter filter can be from 1 to 3.

const hash = window.graphite.updateKycFilter(2)
// => { 
// hash: '0x42d340b0e52ae61f0e004bd1939a3a8d23f02e6e09daf0ed402817948273e9ce',
// data: '0xd1a23b900000000000000000000000000000000000000000000000000000000000000001'
// }

graphite.getLastKycRequest(): Promise<Object>

Returns the latest KYC request data for the user based on the active network.

const lastKycRequest = await window.graphite.getLastKycRequest()
// lastKycRequest => {
//  "address":"0x9684055b99332231F34C27423a0A9d968dBC6379",
//  "lastKycTxHash":"0x42d340b0e52ae61f0e004bd1939a3a8d23f02e6e09daf0ed402817948273e9ce",
//  "centre": "0x8D8129f2F56D87F39a3dEA1ba33a3bd930849F81",
//  "deposite": "0",
//  "level": "1",
//  "status": "0",
//  "statusName": "pending",
//  "uuid": "d05875e9-c9b0-4312-a349-874f6ef317df"
// }

graphite.getActiveNetwork(): Promise<"mainnet" | "testnet">

Returns whether the active network is testnet or mainnet.

const activeNetwork = await window.graphite.getActiveNetwork()
// getActiveNetwork =>  "mainnet"

graphite.changeActiveNetwork(network: "mainnet" | "testnet"): Promise<"mainnet" | "testnet">

Changes the active network to either testnet or mainnet and returns the updated network.

const changeActiveNetwork = await window.graphite.changeActiveNetwork("testnet")
// changeActiveNetwork =>  "testnet"
PreviousGraphite WalletNextGraphite Bridge

Last updated 3 months ago