# Alephium
This feature is supported by the following versions of the SafePal Wallet:
platform | version | description |
---|---|---|
App(iOS) | >=4.8.3 | Mainnet |
App(Android) | >=4.8.3 | Mainnet |
# Methods
# Installed or not
To check if the user has installed SafePal Wallet, perform the following check:
const isSafePalInstalled = window.safepalAlephiumProviders;
1
# Detecting
If the SafePal Wallet is not installed, you can prompt the user to install it by providing the following instructions.
if (!window.safepalAlephiumProviders) {
return window.open('https://www.safepal.com/zh-cn/download');
}
1
2
3
2
3
# SafePal Logo
Retrieve the SafePal logo using the following code:
const logo = window.safepalAlephiumProviders.icon;
1
# Network Id
To get the current network ID:
const networkId = window.safepalAlephiumProviders.connectedNetworkId;
1
# connect
Retrieve the connected account as follows:
const account = window.safepalAlephiumProviders.connectedAccount;
1
# nodeProvider
Retrieve the node provider using:
const node = window.safepalAlephiumProviders.nodeProvider;
1
# signMessage
Sign a message with the following example code:
const msg = "Hello World";
//type MessageHasher = 'alephium' | 'sha256' | 'blake2b' | 'identity';
const params = {"message":msg, "messageHasher":'blake2b'};
const node = window.safepalAlephiumProviders.signMessage(params);
1
2
3
4
2
3
4
# signAndSubmitTransferTx
Submit a transfer transaction with the following options:
const options = {
"signerAddress": "18rQbx5pKtsenFzjFKf3m3hwHEse2iXpWGj6XXu9PPuJJ",
"signerKeyType": "default",
"bytecode": "0101030002004021b41700144020f816465cabdd5e61844010425a5d75aa78c62f0fba7a95675f64823819098b00170116007a0c0c3313190e0d16010101a2144020000000000000000000000000000000000000000000000000000000000000000013c32386f26fc10000a31440200000000000000000000000000000000000000000000000000000000000000000144020722954d9067c5a5ad532746a024f2a9d7a18ed9b90e27d0a3a504962160b560013800057e41348ca0f13190c0c0c0c1400130b0c1601010d",
"attoAlphAmount": "610000000000000000",
"tokens": [
]
};
const txid = window.safepalAlephiumProviders.signAndSubmitTransferTx(options);
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
# signAndSubmitDeployContractTx、signAndSubmitExecuteScriptTx、signAndSubmitUnsignedTx、signUnsignedTx
The following methods—signAndSubmitDeployContractTx, signAndSubmitExecuteScriptTx, signAndSubmitUnsignedTx, and signUnsignedTx—typically follow a similar invocation pattern to signAndSubmitTransferTx.