# MultiversX
This feature is supported by the following versions of SafePal Wallet.
platform | version | description |
---|---|---|
App(iOS) | >=4.7.2 | Mainnet |
App(Android) | >=4.7.2 | Mainnet |
# Methods
# Installed or not
To check if the user has installed SafePal Wallet, perform the below check:
const isSafePalInstalled = window.safepalEGLDProvider;
1
# Detecting
If SafePal Wallet is not installed, you can prompt the user to first install SafePal Wallet and provide the below installation instructions. For example, see below:
if (!window.safepalEGLDProvider) {
return window.open('https://www.safepal.com/zh-cn/download');
}
1
2
3
2
3
# connect
const msg = "Hello World";
window.postMessage({
target: "erdw-inpage",
type: "connect",
data: msg,
}, window.origin);
function event_handler(event) {
if (event.data.target === "erdw-contentScript") {
if (event.data.type === "connectResponse") {
console.log("result:", event.data.data);
}
}
};
window.addEventListener("message", event_handler, false);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# signMessage
const data = {
"account": "erd1m5why7df8nx9lx8mmcy5v3xm4jzp0ndkk05p2ljetyvqcv7rraeqasdx72",
"message": "Hello World"
};
window.postMessage({
target: "erdw-inpage",
type: "signMessage",
data: data,
}, window.origin);
function event_handler(event) {
if (event.data.target === "erdw-contentScript") {
if (event.data.type === "signMessageResponse" || event.data.type === "") {
console.log("result:", event.data.data);
}
}
};
window.addEventListener("message", event_handler, false);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# signTransactions
const data = {
"from": "erd1m5why7df8nx9lx8mmcy5v3xm4jzp0ndkk05p2ljetyvqcv7rraeqasdx72",
"transactions": [
{
"nonce": 81,
"value": "1000000000000000000",
"receiver": "erd1qqqqqqqqqqqqqpgqtmcuh307t6kky677ernjj9ulk64zq74w9l5qxyhdn7",
"sender": "erd1m5why7df8nx9lx8mmcy5v3xm4jzp0ndkk05p2ljetyvqcv7rraeqasdx72",
"gasPrice": 1000000000,
"gasLimit": 60000000,
"data": "cGluZw==",
"chainID": "1",
"version": 2
}
]
};
window.postMessage({
target: "erdw-inpage",
type: "signTransactions",
data: data,
}, window.origin);
function event_handler(event) {
if (event.data.target === "erdw-contentScript") {
if (event.data.type === "signTransactionsResponse" || event.data.type === "") {
console.log("result:", event.data.data);
}
}
};
window.addEventListener("message", event_handler, false);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35