Skip to content

Signing AVM unsignedTX ERROR #973

@goossens0118

Description

@goossens0118

const createUnsignedTx = async (from: string, to: string, amount: number): Promise => {
const avmapi = new avm.AVMApi("https://api.avax.network");

const context = await getContextFromURI("https://api.avax.network");

const { utxos } = await avmapi.getUTXOs({
    addresses: [from],
});

const tx = avm.newBaseTx(
    context,
    [Address.fromString(from).toBytes()],
    utxos,
    [
        TransferableOutput.fromNative(
            context.avaxAssetID,
            BigInt(amount),
            [Address.fromString(to).toBytes()]
        )
    ],
);

console.log('Unsigned Transaction:', tx);
return tx

};

const unsignedTx: UnsignedTx = await createUnsignedTx(from, to, amount);
unsignedTx.addSignature(bech32ToBytes(derSignature));

/*
here the error "Invalid address" occurs when add signature of DER format.
And Signature Class only require 65 bytes format string. - It is R|S|V format for C-Chain.
But X-Chain uses 70~72 bytes format of DER.
*/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions