CityCoins
  • Introduction
  • About CityCoins
    • What are CityCoins?
    • How do I get started?
  • CityCoins Resources
    • General
    • MineCityCoins.com
  • Core Protocol
    • Registration and Activation
    • Mining CityCoins
    • Stacking CityCoins
    • Token Configuration
  • Developer Resources
    • General
    • API
    • Code Examples
      • Get Account Transactions
      • Activation
      • Mining
      • Mining Claims
      • Stacking
    • Contracts
    • Integrations
      • Supporting Stacks
      • Supporting CityCoins
      • Stacks Transactions
      • Additional Info
  • Contract Functions
    • Activation
    • Mining
    • Mining Claims
    • Stacking
    • Stacking Claims
    • Token
Powered by GitBook
On this page
  • Get Activation Block
  • Get Registered Users

Was this helpful?

  1. Developer Resources
  2. Code Examples

Activation

Examples of CityCoin contract functions related to activation and registration.

Get Activation Block

Get the block height the contract activates at.

Requires @stacks/network and @stacks/transactions

// returns the activation block height

const NETWORK = new StacksMainnet(); // set network from @stacks/network

export async function getActivationBlock() {
  const resultCv = await callReadOnlyFunction({
    contractAddress: 'SP466FNC0P7JWTNM2R9T199QRZN1MYEDTAR0KP27',
    contractName: 'miamicoin-core-v1',
    functionName: 'get-activation-block',
    functionArgs: [],
    network: NETWORK, 
    senderAddress: contractAddress, // can be any valid STX address
  });
  const result = cvToJSON(resultCv);
  return result.value.value; // activation block height
}

Get Registered Users

Get the total number of registered users that have sent one of the following:

  • register user tx (register-user)

  • mining tx (mine-tokens or mine-many)

  • stacking tx (stack-tokens)

Requires @stacks/network and @stacks/transactions

// returns the current number of registered users

const NETWORK = new StacksMainnet(); // set network from @stacks/network

export async function getRegisteredUsersNonce() {
  const resultCv = await callReadOnlyFunction({
    contractAddress: 'SP466FNC0P7JWTNM2R9T199QRZN1MYEDTAR0KP27',
    contractName: 'miamicoin-core-v1',
    functionName: 'get-registered-users-nonce',
    functionArgs: [],
    network: NETWORK,
    senderAddress: contractAddress, // can be any valid STX address
  });
  const result = cvToJSON(resultCv);
  return result.value; // total registered users
}
PreviousGet Account TransactionsNextMining

Last updated 3 years ago

Was this helpful?