Methods

requestAccounts

Mainly used for the mina account of the website requesting to connect to the user, if authorized, it will directly return to the current authorized account
1
window.mina.requestAccounts(): Promise<string[]>;
Copied!
1
let accounts
2
// data.result is an array that contains approve account`s address
3
try {
4
accounts = await window.mina.requestAccounts()
5
} catch(error) {
6
// if user reject, requestAccounts will throw an error with code and message filed
7
console.log(error.message, error.code)
8
}
Copied!

sendPayment

sign and broadcast a payment transaction
1
interface SendPaymentArguments {
2
to: string,
3
amount: number,
4
memo?:string
5
}
6
7
window.mina.sendPayment(args: SendPaymentArguments): Promise<{ hash: string }>;
Copied!
1
try {
2
const { hash } = await window.mina.sendPayment({
3
amount: 1,
4
to: "B62qm3V7qSQ97Stgo2MXv4Apof2cVezZyP1VYJ8DfrVNy9yfqKZxLQf",
5
})
6
console.log(hash)
7
} catch (error) {
8
console.log(error.message, error.code)
9
}
Copied!

signStaking

sign and broadcast a delegation transaction
1
interface SendStakeDelegationArguments {
2
to: string,
3
memo?:string
4
}
5
6
mina.sendStakeDelegation(args: SendStakeDelegationArguments): Promise<{ hash: string }>;
7
Copied!
1
try {
2
const { hash } = await window.mina.sendStakeDelegation({
3
to: "B62qq3TQ8AP7MFYPVtMx5tZGF3kWLJukfwG1A1RGvaBW1jfTPTkDBW6",
4
})
5
console.log(hash)
6
} catch (error) {
7
console.log(error.message, error.code)
8
}
Copied!

signMessage

Used to sign information
1
interface SignMessageArguments {
2
message: string
3
}
4
interface SignedData {
5
publicKey: string,
6
payload: string,
7
signature: {
8
field: string,
9
scalar: string
10
}
11
}
12
window.mina.signMessage(args: SignMessageArguments): Promise<SignedData>;
Copied!
1
try {
2
let signResult = await window.mina.signMessage({
3
message: signMessageContent.value,
4
})
5
console.log(signResult)
6
} catch(error) {
7
console.log(error.message, error.code)
8
}
Copied!

verifyMessage

Used to verify signature information
1
interface VerifyMessageArguments {
2
publicKey: string,
3
payload: string,
4
signature: {
5
field: string,
6
scalar: string
7
}
8
}
9
mina.verifyMessage(args: VerifyMessageArguments): Promise<boolean>;
Copied!
1
let messageVerifyResult:boolean = await window.mina.verifyMessage({
2
publicKey: "B62qpjxUpgdjzwQfd8q2gzxi99wN7SCgmofpvw27MBkfNHfHoY2VH32",
3
payload: "message...",
4
signature: {
5
field: "signature filed ...",
6
scalar: "scalar scalar ..."
7
},
8
})
9
Copied!

requestNetwork

request which type of network is using
1
window.mina.requestNetwork(): Promise<'Mainnet' | 'Devnet' | 'Unknown'>;
Copied!
1
const network = await window.mina.requestNetwork();
2
console.log(network); // 'Mainnet' or 'Devnet' or 'Unknown'
Copied!