Getting started

Using the SDK

This package is in development. Please make sure to check if any future updates contain commits that may change the behavior of your application before you upgrade. If you find any issues please report them here.

Authenticate using client credentials


import { MoneriumClient } from '@monerium/sdk'

// The first argument is the environment, either "sandbox" or "production".
// If not specified the default is "sandbox".
const client = new MoneriumClient("sandbox");

await client.auth({
  client_id: "your_client_credentials_uuid"
  client_secret: "your_client_secret"
})

// User is now authenticated, get authentication data
await client.getAuthContext()
  

Authenticate using authorization code flow.


import { MoneriumClient } from '@monerium/sdk'

const client = new MoneriumClient();
// Construct the authFlowUrl for your application and redirect your customer.
let authFlowUrl = client.getAuthFlowURI({
  client_id: "your_client_authflow_uuid"
  redirect_uri: "http://your-webpage.com/monerium-integration"
  // immediately connect a wallet by adding these optional parameters:
  address: "0x0000000000000000000000000000000000000000",
  signature: "0xVALID_SIGNATURE_2c23962f5a2f189b777b6ecc19a395f446c86aaf3b5d1dc0ba919ddb34372f4c9f0c8686cfc2e8266b3e4d8d1bc7bc67c34a11f9dfe8e691b"
  chain: "gnosis",
  network: "chiado",
})
// Retrieve the code verifier to use later.
const codeVerifier = client.codeVerifier;
window.localStorage.setItem("codeVerifier", codeVerifier)
// Redirecting to the Monerium onboarding / Authentication flow.
window.location.replace(authFlowUrl)
As the final step of the flow, the customer will be routed back to the redirect_uri with a code parameter attached to it.
i.e. http://your-webpage.com/monerium-integration?code=1234abcd

const code =  new URLSearchParams(window.location.search).get('code')
await client.auth({
  client_id: "your_client_authflow_uuid",
  code: code,
  code_verifier: window.localStorage.getItem("codeVerifier"),
  redirect_uri: "http://your-webpage.com/monerium-integration"
})

// User is now authenticated, get authentication data
await client.getAuthContext()