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.
*/
const createUnsignedTx = async (from: string, to: string, amount: number): Promise => {
const avmapi = new avm.AVMApi("https://api.avax.network");
};
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.
*/