Onchain transactions with fiat or crypto
Let your users pay for onchain transactions with fiat or crypto on any chain.
Transactions
Let your users pay for onchain transactions with fiat or crypto on any chain.
Amounts are calculated automatically from the transaction, and will get executed after the user has obtained the necessary funds via onramp or swap.
import { claimTo } from "thirdweb/extensions/erc1155";
import { PayEmbed, useActiveAccount } from "thirdweb/react";
function App() {
const account = useActiveAccount();
const { data: nft } = useReadContract(getNFT, {
contract: nftContract,
tokenId: 0n,
});
return (
<PayEmbed
client={client}
payOptions={{
mode: "transaction",
transaction: claimTo({
contract: nftContract,
quantity: 1n,
tokenId: 0n,
to: account?.address,
}),
metadata: nft?.metadata,
}}
/>
);
}
Automatic Onramp
Any transaction with value will automatically trigger onramp to fund the wallet if needed before executing the transaction.
import { trasnfer } from "thirdweb/extensions/erc1155";
import { PayEmbed, useActiveAccount } from "thirdweb/react";
function App() {
const account = useActiveAccount();
return (
<TransactionButton
client={client}
transaction={() => {
if (!account) {
throw new Error("No wallet connected");
}
return transfer({
contract: usdcContract,
amount: "50",
to: account.address,
});
}}
>
Buy VIP Pass
</TransactionButton>
);
}