跳到主要内容

错误

始终用 try / catch 包裹 provider 请求。Pali 会尽可能使用标准 JSON-RPC 和 EIP-1193 风格错误,并为不支持的网络、硬件钱包限制和 Passkey 状态提供钱包特定错误。

try {
await window.ethereum.request({
method: 'eth_sendTransaction',
params: [tx],
});
} catch (error) {
switch (error.code) {
case 4001:
console.log('User rejected the request.');
break;
case 4100:
console.log('The dapp is not authorized.');
break;
case 4200:
console.log('The method is unsupported.');
break;
default:
console.error(error);
}
}

常见类别

代码含义
4001用户拒绝了请求。
4100未授权的账户或方法。
4101方法仅适用于不同的链家族。
4200不支持的方法。
4900Provider 已断开连接。
4901Provider 已从请求的链断开连接。
5710钱包中未为该 EIP-5792 bundle 所在链配置 RPC(wallet_getCallsStatus / wallet_showCallsStatus)。
5720wallet_sendCalls 中 dapp 提供的 EIP-5792 bundle id 重复。
5730wallet_getCallsStatus / wallet_showCallsStatus 中的未知 EIP-5792 bundle id。

更多参考请参阅 错误码