Skip to main content

Signing transaction

This example delegates a Transaction signature to aeWallet.

tip

Ensure that the aeWallet application is running and unlocked before attempting connection.

info

This snippet uses Javascript language to keep things simple.

But @archethicjs/sdk can be used in a TypeScript or Javascript project.

index.html
<html>
<head>
<script type="module" src="main.js"/>
</head>
</html>
main.js
import Archethic from "https://esm.sh/@archethicjs/sdk";

const archethicClient = new Archethic()
await archethicClient.connect()

const txBuilder = archethicClient.transaction
.new()
.setType("token")
.setCode("")
.setContent(JSON.stringify({
name: "NFT 001",
supply: 100000000,
type: "non-fungible",
symbol: "NFT1",
aeip: [2],
properties: {},
}));


await archethicClient.rpcWallet
.signTransactions(
/// Replace by an account available on your wallet
"archethic-wallet-<AccountName>",
"",
[
txBuilder
]
)
.then((signResult) => {
console.log(`Command succeed : ${signResult}`);
})
.catch((signError) => {
/// signError is a JSONRPCError instance.
console.error(`Command failed : ${JSON.stringify(signError)}`);
})

await archethicClient.rpcWallet.close()