就在这个界面的控制台用脚本转就好了, 我昨天也是转了u才发现的, 已经转回欧易去了, 建议先转1u试试先
(async () => {
try {
// ==================================================
// 只需要修改下面 3 项
// ==================================================
const SOURCE_ADDRESS =
'0x这里替换成自己的Fiat24钱包地址';
const DESTINATION_ADDRESS =
'0x这里替换成自己的接收地址';
// 填数字,例如 '1'、'50'、'150.427245'
// 如果要转出全部 USDC,则填写 'ALL'
const AMOUNT_USDC = '1';
// ==================================================
// 以下内容适用于 Arbitrum One 原生 USDC,不要修改
// ==================================================
const USDC_CONTRACT =
'0xaf88d065e77c8cC2239327C5EDb3A432268e5831';
const ARBITRUM_CHAIN_ID = '0xa4b1';
const provider = window.__fiat24Wallet?.provider;
if (!provider?.request) {
throw new Error(
'SESSION_NOT_FOUND:请先运行钱包查找脚本,确认显示 SESSION_READY'
);
}
const isAddress = value =>
/^0x[0-9a-fA-F]{40}$/.test(value);
if (!isAddress(SOURCE_ADDRESS)) {
throw new Error('SOURCE_ADDRESS 格式不正确');
}
if (!isAddress(DESTINATION_ADDRESS)) {
throw new Error('DESTINATION_ADDRESS 格式不正确');
}
const parseUsdc = value => {
const text = String(value).trim();
if (!/^(0|[1-9]\d*)(\.\d{1,6})?$/.test(text)) {
throw new Error('金额格式错误,USDC 最多填写 6 位小数');
}
const [whole, fraction = ''] = text.split('.');
const paddedFraction = fraction.padEnd(6, '0');
return (
BigInt(whole) * 1000000n +
BigInt(paddedFraction)
);
};
const formatUsdc = raw => {
const whole = raw / 1000000n;
const fraction = (raw % 1000000n)
.toString()
.padStart(6, '0')
.replace(/0+$/, '');
return fraction
? `${whole}.${fraction}`
: whole.toString();
};
const [currentAccount] = await provider.request({
method: 'eth_accounts'
});
const chainId = await provider.request({
method: 'eth_chainId'
});
if (
!currentAccount ||
currentAccount.toLowerCase() !== SOURCE_ADDRESS.toLowerCase()
) {
throw new Error(
`当前账户不符:${currentAccount || '没有连接账户'}`
);
}
if (chainId.toLowerCase() !== ARBITRUM_CHAIN_ID) {
throw new Error(
`当前网络不是 Arbitrum One:${chainId}`
);
}
const balanceData =
'0x70a08231' +
currentAccount.slice(2).padStart(64, '0');
const balance = BigInt(
await provider.request({
method: 'eth_call',
params: [
{
to: USDC_CONTRACT,
data: balanceData
},
'latest'
]
})
);
const amount =
AMOUNT_USDC.trim().toUpperCase() === 'ALL'
? balance
: parseUsdc(AMOUNT_USDC);
if (amount <= 0n) {
throw new Error('转账金额必须大于 0');
}
if (amount > balance) {
throw new Error(
`USDC 余额不足,当前余额为 ${formatUsdc(balance)} USDC`
);
}
const transferData =
'0xa9059cbb' +
DESTINATION_ADDRESS.slice(2).padStart(64, '0') +
amount.toString(16).padStart(64, '0');
const transaction = {
from: currentAccount,
to: USDC_CONTRACT,
value: '0x0',
data: transferData
};
const simulation = await provider.request({
method: 'eth_call',
params: [transaction, 'latest']
});
if (simulation !== '0x' && BigInt(simulation) === 0n) {
throw new Error('交易模拟失败,已经停止');
}
const gas = BigInt(
await provider.request({
method: 'eth_estimateGas',
params: [transaction]
})
);
const gasPrice = BigInt(
await provider.request({
method: 'eth_gasPrice'
})
);
const ethBalance = BigInt(
await provider.request({
method: 'eth_getBalance',
params: [currentAccount, 'latest']
})
);
if (ethBalance < gas * gasPrice) {
throw new Error(
'Arbitrum ETH 不足以支付手续费,已经停止'
);
}
const addressSuffix =
DESTINATION_ADDRESS.slice(-6).toLowerCase();
const typed = window.prompt(
`请核对本次转账:\n\n` +
`金额:${formatUsdc(amount)} USDC\n` +
`网络:Arbitrum One\n` +
`发送地址:${currentAccount}\n` +
`接收地址:${DESTINATION_ADDRESS}\n\n` +
`请输入接收地址最后六位:${addressSuffix}`
);
if (
(typed || '').trim().toLowerCase() !== addressSuffix
) {
console.log('CANCELLED');
return;
}
const transactionHash = await provider.request({
method: 'eth_sendTransaction',
params: [transaction]
});
console.log('TX_HASH:', transactionHash);
console.log(
'交易查询:https://arbitrum.blockscout.com/tx/' +
transactionHash
);
} catch (error) {
console.error(
'STOPPED:',
error?.message || error
);
}
})();