createToken method

Future<String> createToken(
  1. AptosAccount account,
  2. String collectionName,
  3. String name,
  4. String description,
  5. int supply,
  6. String uri, {
  7. BigInt? max,
  8. String? royaltyPayeeAddress,
  9. int? royaltyPointsDenominator,
  10. int? royaltyPointsNumerator,
  11. List<String>? propertyKeys,
  12. List<String>? propertyValues,
  13. List<String>? propertyTypes,
  14. BigInt? maxGasAmount,
  15. BigInt? gasUnitPrice,
  16. BigInt? expireTimestamp,
})

Creates a new NFT within the specified account and return the hash of the transaction submitted to the API.

Implementation

Future<String> createToken(
  AptosAccount account,
  String collectionName,
  String name,
  String description,
  int supply,
  String uri,
  {BigInt? max,
  String? royaltyPayeeAddress,
  int? royaltyPointsDenominator,
  int? royaltyPointsNumerator,
  List<String>? propertyKeys,
  List<String>? propertyValues,
  List<String>? propertyTypes,
  BigInt? maxGasAmount,
  BigInt? gasUnitPrice,
  BigInt? expireTimestamp}
) async {
  max ??= MAX_U64_BIG_INT;
  royaltyPayeeAddress ??= account.address;
  royaltyPointsDenominator ??= 0;
  royaltyPointsNumerator ??= 0;
  propertyKeys ??= [];
  propertyValues ??= [];
  propertyTypes ??= [];

  final payload = transactionBuilder.buildTransactionPayload(
    "0x3::token::create_token_script",
    [],
    [
      collectionName,
      name,
      description,
      supply,
      max,
      uri,
      royaltyPayeeAddress,
      royaltyPointsDenominator,
      royaltyPointsNumerator,
      [false, false, false, false, false],
      propertyKeys,
      getPropertyValueRaw(propertyValues, propertyTypes),
      propertyTypes,
    ],
  );

  return aptosClient.generateSignSubmitTransaction(
    account,
    payload,
    maxGasAmount: maxGasAmount,
    gasUnitPrice: gasUnitPrice,
    expireTimestamp: expireTimestamp
  );
}