CityCoins
Search…
Mining Claims
Examples of CityCoin contract functions related to mining claims.

Claim Mining Rewards

Requires:
  • @stacks/network
  • @stacks/transactions
  • @stacks/connect-react
1
// example: claim mining rewards at a given block height
2
3
const NETWORK = new StacksMainnet(); // set network from @stacks/network
4
const { doContractCall } = useConnect(); // hook for Stacks Connect
5
6
const targetBlock = 24498; // block height to claim
7
const targetBlockCV = uintCV(targetBlock);
8
9
try {
10
await doContractCall({
11
contractAddress: 'SP466FNC0P7JWTNM2R9T199QRZN1MYEDTAR0KP27',
12
contractName: 'miamicoin-core-v1',
13
functionName: 'claim-mining-reward',
14
functionArgs: [targetBlockCV],
15
postConditionMode: PostConditionMode.Deny,
16
postConditions: [],
17
network: NETWORK,
18
onCancel: () => {
19
// what to do if tx is canceled / window is closed
20
console.log('Transaction canceled, please try again');
21
},
22
onFinish: result => {
23
// what to if tx is successfully broadcasted
24
console.log(`Transaction successfully broadcasted:\n${result.txId}`);
25
},
26
});
27
} catch (err) {
28
console.log(`Error: ${err.message}`);
29
}
Copied!
Last modified 6mo ago
Copy link