1

when i wanna transfer chainlink on goerli network with ledger i get this error:

TransportStatusError: Ledger device: Invalid data received (0x6a80)

contractAddress: 0x326c977e6efc84e512bb9c30f76e30c160ed06fb

I can send DAI but when I wanna send chainlink I get this error.

please help. Thanks!

My environment:

  • windows
  • Device (Nano S)

I'm using this libraries:

  • "@ledgerhq/hw-app-eth": "^6.31.0"
  • "@ledgerhq/hw-transport-webhid": "^6.27.11"

This is the transaction:

{
"gasLimit": "0x8792",
"to": "0x326c977e6efc84e512bb9c30f76e30c160ed06fb",
"data": "0xa9059cbb00000000000000000000000014be4dc6e2e7562eb80f20fa4f8dbd072b8a56670000000000000000000000000000000000000000000000000de0b6b3a7640000",
"nonce": "0x4b",
"chainId": "0x5",
"type": 2,
"maxPriorityFeePerGas": "0x59682f00",
"maxFeePerGas": "0x101f0aef2a"
}

and this is the code

const web3 = new Web3(getNet(secondAddress));
const abi = getAbi8();
const contract = new web3.eth.Contract(abi, contractAddress.toLowerCase(), { from: wallet.address });
const decimals = await contract.methods.decimals().call();
const value = amount * (10 ** decimals);
const gas = await contract.methods.transfer(toAddress.toLowerCase(), String(value)).estimateGas({ from: wallet.address });
const gasPrice = await web3.eth.getGasPrice();
const transactionCount = await web3.eth.getTransactionCount(wallet.address, 'pending');
const chainId = await getChainId();
let feeData = await getFeeData(secondAddress);

let transaction = {
    gasLimit: ethers.utils.hexlify(gas),
    to: contractAddress,
    data: (contract.methods.transfer(toAddress.toLowerCase(), web3.utils.toHex(value)).encodeABI()),
    gasPrice: web3.utils.toHex(Math.floor(gasPrice * 1.3)),
    nonce: web3.utils.toHex(transactionCount),
    chainId: web3.utils.toHex(chainId),
    type: 2
}

if (feeData.maxPriorityFeePerGas) {
    transaction.maxPriorityFeePerGas = web3.utils.toHex(feeData.maxPriorityFeePerGas);
    delete transaction.gasPrice;
}
if (feeData.maxFeePerGas) {
    transaction.maxFeePerGas = web3.utils.toHex(feeData.maxFeePerGas);
}

if (!feeData.maxPriorityFeePerGas) {
    transaction.gasPrice = feeData.gasPrice;
}

const gasData = localStorage.getItem('user-gas');

if (gasData) {

    const _gasData = JSON.parse(gasData);
    if (_gasData.gasLimit) {
        transaction.gas = web3.utils.toHex(_gasData?.gasLimit);
    }
    if (_gasData.gasPrice && !feeData.maxPriorityFeePerGas) {
        transaction.gasPrice = web3.utils.toHex(_gasData?.gasPrice * 10 ** 9);
    }
    if (_gasData.maxGas) {
        transaction.maxFeePerGas = web3.utils.toHex(_gasData?.maxGas * 10 ** 9);
    }
    if (_gasData.maxPriorityFee) {
        transaction.maxPriorityFeePerGas = web3.utils.toHex(_gasData?.maxPriorityFee * 10 ** 9);
    }
}

if (customGas && !feeData.maxFeePerGas) {
    /// convert gasprice from gwei to wei
    transaction.gasPrice = web3.utils.toHex(customGas.gasPrice);
}
else if (customGas && feeData.maxFeePerGas) {
    transaction.maxPriorityFeePerGas = web3.utils.toHex(customGas.priorityFeePerGas);
}

console.log(transaction)

const serializedTx = ethers.utils.serializeTransaction(transaction).slice(2)
await forgetDevice()
let appEth
try {
    let transport = await Transport.request();
    appEth = await new Eth(transport)
}
catch (err) {
    throw 'Unable to connect with your ledger device , make sure your device is connected and keep the app open';
}

let path = `/44'/60'/${wallet.id - 1}'/0/0`;
if (wallet.ledgerType == 3) {
    path = `44'/60'/0'/0/${wallet.id - 1}`;
}
else if (wallet.ledgerType == 2) {
    path = `m/44'/60'/0'/${wallet.id - 1}`;
}

const resolution = await ledgerService.resolveTransaction(
    serializedTx,
    appEth.loadConfig,
    {
        externalPlugins: true,
        erc20: true,
        nft: true,
    }
);

const signature = await appEth.signTransaction(path, serializedTx, resolution)
signature.r = "0x" + signature.r;
signature.s = "0x" + signature.s;
signature.v = parseInt("0x" + signature.v);
signature.from = wallet.address;
const signedTx = ethers.utils.serializeTransaction(transaction, signature);
return new Promise((resolve, reject) => {

    web3.eth.sendSignedTransaction(signedTx, (err, hash) => {
        if (!err) {
            resolve(hash);
        }
        else {
            reject(err)
        }
    })

})

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy