68 lines
1.9 KiB
JavaScript
68 lines
1.9 KiB
JavaScript
|
|
import { createPublicClient, createWalletClient, http, parseEther } from 'viem'
|
||
|
|
import { arbitrumSepolia } from 'viem/chains'
|
||
|
|
import { privateKeyToAccount } from 'viem/accounts'
|
||
|
|
|
||
|
|
const publicClient = createPublicClient({
|
||
|
|
chain: arbitrumSepolia,
|
||
|
|
transport: http('https://api.zan.top/node/v1/arb/sepolia/baf84c429d284bb5b676cb8c9ca21c07')
|
||
|
|
})
|
||
|
|
|
||
|
|
const LENDING_PROXY = '0xCb4E7B1069F6C26A1c27523ce4c8dfD884552d1D'
|
||
|
|
const YT_A = '0x97204190B35D9895a7a47aa7BaC61ac08De3cF05'
|
||
|
|
|
||
|
|
const LENDING_ABI = [
|
||
|
|
{
|
||
|
|
inputs: [
|
||
|
|
{ internalType: 'address', name: 'asset', type: 'address' },
|
||
|
|
{ internalType: 'uint256', name: 'amount', type: 'uint256' }
|
||
|
|
],
|
||
|
|
name: 'supplyCollateral',
|
||
|
|
outputs: [],
|
||
|
|
stateMutability: 'nonpayable',
|
||
|
|
type: 'function'
|
||
|
|
}
|
||
|
|
]
|
||
|
|
|
||
|
|
async function main() {
|
||
|
|
console.log('\n尝试捕获详细错误...\n')
|
||
|
|
|
||
|
|
try {
|
||
|
|
// 尝试估算 gas
|
||
|
|
const gasEstimate = await publicClient.estimateContractGas({
|
||
|
|
address: LENDING_PROXY,
|
||
|
|
abi: LENDING_ABI,
|
||
|
|
functionName: 'supplyCollateral',
|
||
|
|
args: [YT_A, parseEther('10')],
|
||
|
|
account: '0xa013422A5918CD099C63c8CC35283EACa99a705d'
|
||
|
|
})
|
||
|
|
|
||
|
|
console.log('✓ Gas 估算成功:', gasEstimate.toString())
|
||
|
|
|
||
|
|
} catch (error) {
|
||
|
|
console.log('✗ Gas 估算失败\n')
|
||
|
|
console.log('错误类型:', error.name)
|
||
|
|
console.log('错误消息:', error.shortMessage || error.message)
|
||
|
|
|
||
|
|
if (error.cause) {
|
||
|
|
console.log('\n详细原因:')
|
||
|
|
console.log(' Reason:', error.cause.reason)
|
||
|
|
console.log(' Details:', error.cause.details)
|
||
|
|
|
||
|
|
// 尝试解析 revert 原因
|
||
|
|
if (error.cause.data) {
|
||
|
|
console.log(' Raw Data:', error.cause.data)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if (error.details) {
|
||
|
|
console.log('\n更多细节:', error.details)
|
||
|
|
}
|
||
|
|
|
||
|
|
// 打印完整错误用于调试
|
||
|
|
console.log('\n=== 完整错误对象 ===')
|
||
|
|
console.log(JSON.stringify(error, null, 2))
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
main()
|