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)

Response

Address Response Properties

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
  protocol?: string
}

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

Where protocol accepts either 'BIP322' or 'ECDSA' and defaults to the former if no value is provided. By default all signatures will follow the up to date bip322 standard, but certain apps require legacy signing. Passing in 'ECDSA' will ensure legacy signing only for segwit/payment addresses.

Response

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)

Response

SignTransactionResponse Response Properties

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)

Response

signMultipleTransactions (custom)

Prompts to sign multiple PSBTs under one approval with the user's connected Magic Eden Wallet account. This is currently a private wallet method that is whitelisted to the magic eden marketplace domain

Params

This is a custom feature of the Magic Eden Wallet and thus cannot be invoked with sats-connect, as you have the choice to do with the other provider methods. Rather, you can call this method with a similar request string as signTransaction

import * as jsontokens from 'jsontokens'

const payload: any = {
  network: {
    type: 'Mainnet',
  },
  message: 'Sign Multiple Transactions dummy message',
  psbts: [
    {
      psbtBase64:
        'cHNidP8BAIkCAAAAAcdT+1joxn7quCzc5RHnqjiUO3odlGn2dznH7/QY4uwlAgAAAAD/////AugDAAAAAAAAIgAgQw4WXibgytGq1y25JPXvYiECxZCpUo6L31w+KfQtgk2HmQAAAAAAACIAIEMOFl4m4MrRqtctuST172IhAsWQqVKOi99cPin0LYJNAAAAAAABASv4pwAAAAAAACIAIEMOFl4m4MrRqtctuST172IhAsWQqVKOi99cPin0LYJNAQMEggAAAAEFR1IhA9/z2Wg/zWhuy2Wtm8KZC+NuwqQzhN3PG+L5GrmOOecFIQP3thdmUgZQrE2gZFZt1red4El15NcoNxCj6syNnj19i1KuAAAA',
      inputsToSign: [
        {
          address,
          signingIndexes: [1],
          sigHash: 0x82,
        },
      ],
    },
    {
      psbtBase64:
        'cHNidP8BAFMCAAAAAYZhHMQ1Mjf1j3mtKvSHg128Nird1Lz62NyvyCF+xvG/AQAAAAD/////ATCmBwAAAAAAF6kUoaCqiRUca/0Ct3DHsaLnYllpTLiHAAAAAAj8Am1lA3NpZ0ALaP+AC+tlBfBS6QdQEv1c8blRxYKVxCdL/MEmw1DMoQEWySlU3ejsBZ+Nh+IjpAWUWYyOSdmpJgdUmPfvolpdC/wCbWUGc2lnZXhwCEJ5Hs28doAAAAEBKyICAAAAAAAAIlEg39xRNMrlIZlVJKDvuPjChZEYR0U314t+SXHBxHd08SMBAwSDAAAAARcgSuLJW58BUTAvZxKpS0E4abC/u9pAXsb/SeTXM/CrP/MADvwCbWUJcHJpY2VTYXRzBjUwMDAwMAA=',
      inputsToSign: [
        {
          address: addressOrdinals,
          signingIndexes: [0],
          sigHash: 0x83,
        },
      ],
    },
  ],
}

const request = jsontokens.createUnsecuredToken(payload)

You can then pass this stringified request into the provider method like so: window.magicEden.bitcoin.signMultipleTransactions(request)

Response

SignTransactionResponse Response Properties

Last updated