Buy
Allows you to buy an item from the marketplace. Address is optional if you already have an address associated with your account.Fee
The fee is a percentage of the total price of the item. The fee is set by the person implementing the buy. The maximum fee is 10%.import { mkt } from './config'
mkt.buy(
{
id: '<ITEM_MARKETPLACE_ID>',
amount: 1n,
mailingAddress: {
name: "John Doe",
phone: "+12024564545", // US or Canada phone number
street1: "123 Main St",
city: "Anytown",
state: "CA",
country: "USA",
zip: "12345"
},
email: "[email protected]"
fee: 300, // 3%
feeRecipient: "0x123...",
}
)
import type { Address } from 'viem'
buy(input: BuyInput): Promise<void>
export interface BuyInput {
id: string
amount: bigint
mailingAddress: MailingAddress | undefined // optional, account may have address
email: string | undefined // optional, account may have email
fee: number
feeRecipient: Address
}
interface MailingAddress {
name: string
phone: string
street1: string
street2: string
city: string
state: string
country: string
zip: string
}
import { Marketplace } from '@evav/marketplace'
import { useDynamicContext, getAuthToken } from '@dynamic-labs/sdk-react-core'
const { primaryWallet } = useDynamicContext()
const walletClient = await primaryWallet?.connector?.getWalletClient()
const publicClient = await primaryWallet?.connector?.getPublicClient()
const [account] = await walletConnector.getConnectedAccounts()
// viem is required for the evav sdk
export const mkt = new Marketplace({
walletClient,
publicClient,
account: account as Address,
// Optional. If not provided, SIWE will be used instead, and you will be asked to sign a message with your wallet
accessToken: getAuthToken(),
})
import { Marketplace } from '@evav/marketplace'
import { useWallets, usePrivy } from 'privy'
import { createWalletClient, createPublicClient, custom } from 'viem'
import { base } from 'viem/chains'
const { wallets } = useWallets();
const { user } = usePrivy();
const wallet = wallets[0]; // Replace this with your desired wallet
const provider = await wallet.getEthereumProvider()
const walletClient = createWalletClient({
chain: base,
transport: custom(provider),
})
const publicClient = createPublicClient({
chain: base,
transport: custom(provider),
})
// viem is required for the evav sdk
export const mkt = new Marketplace({
walletClient,
publicClient,
account: user.linked_accounts[0].address // Replace with your desired account
})