The type string, for example 0x1::coin::CoinStore<0x1::supra_coin::SupraCoin>.
The TypeTag of the type.
Error when the string is not exactly one type: text after the type, an unknown type name, a generic type
parameter such as T0 (type arguments are concrete types), an address of more than 64 hex digits, or more than
eight nested vector and struct levels (the most a transaction can carry; primitive types are not a level, so
vector nested eight times around u8 is accepted and nine times is refused).
import { BCS, Network, SupraAccount, SupraClient, parseTypeArgument } from "supra-ts-sdk";
const supra = new SupraClient({ network: Network.TESTNET });
const sender = new SupraAccount(); // the signing account
const rawTxn = supra.transaction.build.rawTxnObject({
senderAddress: sender.address(),
senderSequenceNumber: 0n, // the account's sequence number, obtained separately
function: "0x1::supra_account::transfer_coins",
functionTypeArgs: [parseTypeArgument("0x1::supra_coin::SupraCoin")],
functionArgs: [new SupraAccount().address().toUint8Array(), BCS.bcsSerializeUint64(1_000n)],
optionalTransactionPayloadArgs: { maxGas: 5_000n, gasUnitPrice: 100_000n },
});
const metadata = parseTypeArgument("0x1::object::Object<0x1::fungible_asset::Metadata>"); // a struct type tag
Parses a Move type string given as a type argument into a
TypeTag.The grammar is the one Supra nodes parse: a primitive type (
bool,u8tou256,address,signer),vector<T>, or a structaddress::module::Namewith optional type parameters<T1, T2>. Addresses are0xfollowed by 1 to 64 hex digits; whitespace between tokens is allowed, and so is a comma after the last type parameter. A struct type keeps its address, module, name and type parameters, so0x1::object::Object<0x1::fungible_asset::Metadata>is the structObjectwith the type parameterMetadata. The SDK parses type argument strings with this function; use it to build theTypeTags of builders that takeTypeTags, such astransaction.build.rawTxnObject.TypeTagParserofsupra-l1-sdk-coreparses0x1::object::Object<T>asaddressand refuses names that containTfollowed by digits, such asUSDT0.