Provider API Methods

Using the Sats Connect methods is the easiest way to format the request strings that get passed down to our actual provider method parameters. Below is all of the methods we support directly on the provider.

Provider Methods

Connect

Prompts a connection to a user's Magic Eden Wallet account.

Params

Without using Sats Connect, you could encode your request payload like below. However, getAddress takes care of this for you

import * as jsontokens from 'jsontokens'

enum AddressPurposes {
  PAYMENT = 'payment',
  ORDINALS = 'ordinals',
}

const payload = {
  purposes: [AddressPurposes.PAYMENT, AddressPurposes.ORDINALS],
}
const request = jsontokens.createUnsecuredToken(payload)

Property

Type

Description

request

string

The json encoded payload

Response

PropertyTypeDescription

Promise<getAddressRespose>

array

Array of the connected user’s Address objects

Address Response Properties

PropertyTypeDescription

address

string

The user's BTC address

publicKey

string

A hex string representing the full publicKey of your BTC account. Your address is shortened from this

purpose

enum - 'payment' | 'ordinals'

The purpose of the address is used to indicate whether this address is preferrably used for payments or ordinals/runes

signMessage

Prompts to sign a message with the user's connected Magic Eden Wallet account

Params

Without using Sats Connect, you could encode your request payload like below. However, signMessage takes care of this for you

import * as jsontokens from 'jsontokens'

export interface SignMessagePayload {
  address: string
  message: string
}

const payload = {
  'bc1qcdmvsc8qqk8sr2st3mttu6fsmfrjzh5xrf4dch',
  'Welcome to my dApp!',
}
const request = jsontokens.createUnsecuredToken(payload)

Property

Type

Description

request

string

The json encoded payload

Response

PropertyTypeDescription

Promise<string>

string

String containing the signature

signTransaction

Prompts to sign a PSBT with the user's connected Magic Eden Wallet account.

Params

Without using Sats Connect, you could encode your request payload like below. However, signTransaction takes care of this for you

import * as jsontokens from 'jsontokens'

const payload: any = {
  network: {
    type: 'Mainnet',
  },
  message: 'wow',
  psbtBase64: `cHNidP8BAIkCAAAAAcdT+1joxn7quCzc5RHnqjiUO3odlGn2dznH7/QY4uwlAgAAAAD/////AugDAAAAAAAAIgAgQw4WXibgytGq1y25JPXvYiECxZCpUo6L31w+KfQtgk2HmQAAAAAAACIAIEMOFl4m4MrRqtctuST172IhAsWQqVKOi99cPin0LYJNAAAAAAABASv4pwAAAAAAACIAIEMOFl4m4MrRqtctuST172IhAsWQqVKOi99cPin0LYJNAQMEggAAAAEFR1IhA9/z2Wg/zWhuy2Wtm8KZC+NuwqQzhN3PG+L5GrmOOecFIQP3thdmUgZQrE2gZFZt1red4El15NcoNxCj6syNnj19i1KuAAAA`,
  broadcast: false,
  inputsToSign: [
    {
      address,
      signingIndexes: [1],
    },
  ],
}

if (sigHash) {
  payload.inputsToSign[0].sigHash = sigHash
}

const request = jsontokens.createUnsecuredToken(payload)

Property

Type

Description

request

string

The json encoded payload

Response

PropertyTypeDescription

Promise<SignTransactionResponse>

object

Array of the connected user’s Address objects

SignTransactionResponse Response Properties

PropertyTypeDescription

psbtBase64

string

The base64 encoded psbt string

txId

string

an optional transaction Id on success

sendBtcTransaction

Prompts to send BTC from the user's connected Magic Eden Wallet account.

Params

Without using Sats Connect, you could encode your request payload like below. However, sendBtcTransaction takes care of this for you

import * as jsontokens from 'jsontokens'

const payload: any = {
  recipients: [
    {
      // recipient BTC address
      'bc1qcdmvsc8qqk8sr2st3mttu6fsmfrjzh5xrf4dch',
      amountSats: `3000`,
    },
  ],
  senderAddress: address,
}

const request = jsontokens.createUnsecuredToken(payload)

Property

Type

Description

request

string

The json encoded payload

Response

PropertyTypeDescription

Promise<string>

string

String containing the transaction Id

Last updated