ioPay's mobile in-app browser will both inject a ioPay object into the window of any web application the user visits. ioPay will not inject the provider into iframes or sites using http://.
If a ioPay object exists, Bitcoin & Ordinals dApps can interact with ioPay via the API found at window.ioPay.solana. To detect if ioPay is installed, an application should check for an additional isIoPay flag like so:
const provider = getProvider();
const transaction = new Transaction();
const signedTransaction = await provider.signTransaction(transaction);
// After the transaction has been signed, an application may submit the transaction itself via web3js
const network = "<NETWORK_URL>";
const connection = new Connection(network);
const signature = await connection.sendRawTransaction(signedTransaction.serialize());
// The following example show how to build a simple transfer instruction.
const instructions = [
SystemProgram.transfer({
fromPubkey: publicKey,
toPubkey: publicKey,
lamports: 10,
}),
];
// create v0 compatible message
const messageV0 = new TransactionMessage({
payerKey: publicKey,
recentBlockhash: blockhash,
instructions,
}).compileToV0Message();
const provider = getProvider();
// make a versioned transaction
const transactionV0 = new VersionedTransaction(messageV0);
const { signature } = await provider.signAndSendTransaction(transactionV0);
// check transaction status
const network = "<NETWORK_URL>";
const connection = new Connection(network);
await connection.getSignatureStatus(signature);
Signing a Message
Method
signMessage - Send a message for the user to sign, request that the encoded message is signed via the user's ioPay wallet
Returns:
Promise - String
Example:
const provider = getProvider(); // see "Detecting the Provider"
const message = `Welcome to XXXXX`;
const encodedMessage = new TextEncoder().encode(message);
const signedMessage = await provider.signMessage(encodedMessage, "utf8")