Magic Eden Wallet Developer Docs
  • 👋Welcome
    • Wallet Introduction
  • 📙Bitcoin
    • Diving into Bitcoin
    • Detecting the Provider
    • Connecting to the Wallet
    • Signing a Message
    • Signing a Transaction
    • Sending BTC
    • Provider API Methods
    • Provider Events
    • FAQs
  • 📗Solana
    • Diving Into Solana
    • Solana Wallet Adapter
    • Connect Directly to the ME Solana Provider
    • Signing a Message
    • Sending a Transaction
    • Provider API Methods
    • Provider Events
    • FAQs
  • 📘EVM
    • Diving into the EVM
    • Connect Directly to the ME EVM Provider
    • Signing a Message
    • Sending a Transaction
    • Library Integrations
      • Wallet Connect
      • Rainbow Kit
      • Wagmi
    • Provider API Methods
    • Provider Events
    • FAQs
  • ❓Resources
    • Demo Apps
    • Logos and Brand Assets
Powered by GitBook
On this page
  • Provider Methods
  • Connect
  • signMessage
  • signTransaction
  • sendBtcTransaction
  • signMultipleTransactions (custom)
  1. Bitcoin

Provider API Methods

PreviousSending BTCNextProvider Events

Last updated 6 months ago

Using the 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, 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

Property
Type
Description

Promise<getAddressRespose>

array

Array of the connected user’s Address objects

Address Response Properties

Property
Type
Description

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

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)

Property

Type

Description

request

string

The json encoded payload

Response

Property
Type
Description

Promise<string>

string

String containing the signature

signTransaction

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

Params

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

Property
Type
Description

Promise<SignTransactionResponse>

object

The returned psbt in base64 and the txId

SignTransactionResponse Response Properties

Property
Type
Description

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

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

Property
Type
Description

Promise<string>

string

String containing the transaction Id

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)

Property

Type

Description

request

string

The json encoded payload

Response

Property
Type
Description

Promise<SignTransactionResponse[]>

object

Array of the returned psbt in base64 and the txId

SignTransactionResponse Response Properties

Property
Type
Description

psbtBase64

string

The base64 encoded psbt string

txId

string

an optional transaction Id on success

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

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 standard, but certain apps require legacy signing. Passing in 'ECDSA' will ensure legacy signing only for segwit/payment addresses.

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

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

📙
Sats Connect methods
getAddress
signMessage
bip322
signTransaction
sendBtcTransaction