The createAtomicAsset function allows you to create a new Atomic Asset as per Arweave Tradable Atomic Asset Specification.

Basic Syntax

The function is called as follows:

const tx = await toolkit.assets.createAtomicAsset(file, opts);

Input Parameters

The function takes the following input parameters:

  • file: File | string: The Asset file for the Atomic Asset. For toolkit initialized for server-side usage with Irys the file should be a relative path to the file from the root of the project.
  • opts: CreateTradableAssetOpts: The options for the Atomic Asset. For details on the options see the Create Tradable Asset Options section.
    • initialState: TradableAssetInitState: The object containing Initial state of the Atomic Asset. It contains feilds like name, ticker, balances and claimable. For details on the options see the Tradable Asset Initial State section.
    • discoverability: DiscoverabilityTags: The discoverability tags for the Atomic Asset as per ANS-110 Specification. Contains feilds like title, description, type and topics. For details on the options see the Discoverability Tags section.
    • license (optional): LicenseTags: Universal Data License Tags for the Asset. By default base UDL tags will be used. For details on the options see the License Tags section.
    • contractIdentifier (optional): ContractIdentifierTags: Contract Identifiers tags. use this only if you want to use a custom contract. Fo r details on the options see the Contract Identifier Tags section.
    • indexWithUCM (optional): boolean: Whether to index the Atomic Asset with UCM. Defaults to true.
    • additionalTags (optional): Tag[]: Additional tags for the Atomic Asset. Duplicate tags will throw an error. For details on the options see the Tag section.

NodeIrys only supports file paths so if you are using AtomicToolkit in server-side mode with Irys then you must pass the file path as the first argument to the function.

Return Value

The return value is a Promise that resolves to the ContractDeploy. It has the following properties:

  • contractTxId: string: The transaction ID of the Atomic Asset contract.
  • srcTxId: string: The transaction ID of the Atomic Asset contract source.

Example Usage

const tx = await toolkit.assets.createAtomicAsset(image, {
    initialState: {
        name: 'Atomic Asset',
        ticker: 'ATOMIC',
        description: 'Atomic Asset description',
        balances: {
            'Z7t5Dw42qalSx9-1u4wINXWayX7Ktu_i3sbc31tSDb4': 1,
        },
        claimable: [],
    },
    discoverability: {
        title: 'Atomic Asset',
        description: 'Atomic Asset description',
        type: 'image',
    },
    license: {
        license: 'yRj4a5KMctX_uOmKWCFJIjmY8DeJcusVk6-HzLiM_t8',
        commercialUse: 'Allowed',
    },
});