CityCoins
Search…
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
1
// returns the activation block height
2
3
const NETWORK = new StacksMainnet(); // set network from @stacks/network
4
5
export async function getActivationBlock() {
6
const resultCv = await callReadOnlyFunction({
7
contractAddress: 'SP466FNC0P7JWTNM2R9T199QRZN1MYEDTAR0KP27',
8
contractName: 'miamicoin-core-v1',
9
functionName: 'get-activation-block',
10
functionArgs: [],
11
network: NETWORK,
12
senderAddress: contractAddress, // can be any valid STX address
13
});
14
const result = cvToJSON(resultCv);
15
return result.value.value; // activation block height
16
}
Copied!

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
1
// returns the current number of registered users
2
3
const NETWORK = new StacksMainnet(); // set network from @stacks/network
4
5
export async function getRegisteredUsersNonce() {
6
const resultCv = await callReadOnlyFunction({
7
contractAddress: 'SP466FNC0P7JWTNM2R9T199QRZN1MYEDTAR0KP27',
8
contractName: 'miamicoin-core-v1',
9
functionName: 'get-registered-users-nonce',
10
functionArgs: [],
11
network: NETWORK,
12
senderAddress: contractAddress, // can be any valid STX address
13
});
14
const result = cvToJSON(resultCv);
15
return result.value; // total registered users
16
}
Copied!
Last modified 1mo ago