Signing
The following example shows how to initiate a Stellar transaction, Auth Entry and message signature via window.$ukey.stellar. Please read the address and networkPassphrase before signing to ensure that the network confirmed by the user is consistent with the business goals.
Signature transaction XDR
const { address } = await stellar.getAddress();
const { networkPassphrase } = await stellar.getNetwork();
const { signedTxXdr, signerAddress } = await stellar.signTransaction(
unsignedXdr,
{
networkPassphrase,
address,
// submit: false, // 如果只签名不提交可以这样配
// submitUrl: 'https://horizon.stellar.org/transactions', // 也能自定义提交节点
},
);
console.log({ signedTxXdr, signerAddress });
Signature Auth Entry (Soroban Authorization Entry)
const { address } = await stellar.getAddress();
const { networkPassphrase } = await stellar.getNetwork();
const { signedAuthEntry, signerAddress } = await stellar.signAuthEntry(
authEntryXdr,
{
networkPassphrase,
address,
},
);
console.log({ signedAuthEntry, signerAddress });
Approve msg
const { address } = await stellar.getAddress();
const { networkPassphrase } = await stellar.getNetwork();
const { signedMessage, signerAddress } = await stellar.signMessage(
"hello stellar",
{
networkPassphrase,
address,
},
);
console.log({ signedMessage, signerAddress });