@stacks/stacking
Advanced tools
Comparing version 3.0.0-beta.0 to 3.0.0
@@ -6,8 +6,24 @@ # Change Log | ||
# [3.0.0-beta.0](https://github.com/blockstack/blockstack.js/compare/v2.0.0-beta.1...v3.0.0-beta.0) (2021-07-20) | ||
## [2.0.1](https://github.com/blockstack/blockstack.js/compare/v2.0.1-beta.2...v2.0.1) (2021-08-09) | ||
**Note:** Version bump only for package @stacks/stacking | ||
## [2.0.1-beta.2](https://github.com/blockstack/blockstack.js/compare/v2.0.1-beta.1...v2.0.1-beta.2) (2021-08-06) | ||
**Note:** Version bump only for package @stacks/stacking | ||
## [2.0.1-beta.1](https://github.com/blockstack/blockstack.js/compare/v2.0.0-beta.1...v2.0.1-beta.1) (2021-07-26) | ||
### Features | ||
* refactor all js `number` and `bn.js` usages in Clarity integer values to native bigint ([1d0908e](https://github.com/blockstack/blockstack.js/commit/1d0908ef67cafbc09623adbcac54d85e92e174a0)) | ||
* refactor all js `number` and `bn.js` usages in Clarity integer values to native bigint ([1f78339](https://github.com/blockstack/blockstack.js/commit/1f783397e7f5b38aabb6e0342af71b58022aed4c)) | ||
@@ -18,2 +34,13 @@ | ||
# [2.0.0-beta.2](https://github.com/blockstack/blockstack.js/compare/v2.0.0-beta.1...v2.0.0-beta.2) (2021-07-26) | ||
### Features | ||
* refactor all js `number` and `bn.js` usages in Clarity integer values to native bigint ([1f78339](https://github.com/blockstack/blockstack.js/commit/1f783397e7f5b38aabb6e0342af71b58022aed4c)) | ||
## [1.4.1](https://github.com/blockstack/blockstack.js/compare/v1.4.1-alpha.0...v1.4.1) (2021-04-20) | ||
@@ -20,0 +47,0 @@ |
import { Buffer, intToBigInt } from '@stacks/common'; | ||
import { makeContractCall, bufferCV, uintCV, tupleCV, ClarityType, broadcastTransaction, standardPrincipalCV, callReadOnlyFunction, cvToString, noneCV, someCV, validateStacksAddress, AnchorMode, } from '@stacks/transactions'; | ||
import { makeContractCall, bufferCV, uintCV, tupleCV, ClarityType, broadcastTransaction, standardPrincipalCV, callReadOnlyFunction, cvToString, noneCV, someCV, validateStacksAddress, AnchorMode, getFee, } from '@stacks/transactions'; | ||
import BN from 'bn.js'; | ||
@@ -341,3 +341,3 @@ import { StackingErrors } from './constants'; | ||
modifyLockTxFee({ tx, amountMicroStx }) { | ||
const fee = tx.auth.getFee(); | ||
const fee = getFee(tx.auth); | ||
tx.payload.functionArgs[0] = uintCV(intToBigInt(amountMicroStx, false) - fee); | ||
@@ -344,0 +344,0 @@ return tx; |
@@ -357,3 +357,3 @@ "use strict"; | ||
modifyLockTxFee({ tx, amountMicroStx }) { | ||
const fee = tx.auth.getFee(); | ||
const fee = transactions_1.getFee(tx.auth); | ||
tx.payload.functionArgs[0] = transactions_1.uintCV(common_1.intToBigInt(amountMicroStx, false) - fee); | ||
@@ -360,0 +360,0 @@ return tx; |
{ | ||
"name": "@stacks/stacking", | ||
"version": "3.0.0-beta.0", | ||
"version": "3.0.0", | ||
"description": "Library for Stacking.", | ||
@@ -37,6 +37,6 @@ "keywords": [ | ||
"dependencies": { | ||
"@stacks/common": "^3.0.0-beta.0", | ||
"@stacks/network": "^1.2.2", | ||
"@stacks/common": "^3.0.0", | ||
"@stacks/network": "^3.0.0", | ||
"@stacks/stacks-blockchain-api-types": "^0.61.0", | ||
"@stacks/transactions": "^3.0.0-beta.0", | ||
"@stacks/transactions": "^3.0.0", | ||
"@types/bn.js": "^4.11.6", | ||
@@ -64,3 +64,3 @@ "bitcoinjs-lib": "^5.2.0", | ||
"unpkg": "dist/index.umd.js", | ||
"gitHead": "74e07902c986168aa48d34adb47a46de88bc2cdc" | ||
"gitHead": "728b58358f2876d282f511ba1fc6c4fa9a1ac2f3" | ||
} |
165
README.md
@@ -8,3 +8,3 @@ # @stacks/stacking [![npm](https://img.shields.io/npm/v/@stacks/stacking?color=red)](https://www.npmjs.com/package/@stacks/stacking) | ||
```shell | ||
npm install @stacks/stacking bn.js | ||
npm install @stacks/stacking | ||
``` | ||
@@ -19,13 +19,15 @@ | ||
```typescript | ||
import { getNonce } from '@stacks/transactions'; | ||
import { StacksTestnet, StacksMainnet } from '@stacks/network'; | ||
import { StackingClient } from '@stacks/stacking'; | ||
import BN from 'bn.js'; | ||
// for mainnet: const network = new StacksMainnet(); | ||
const network = new StacksTestnet(); | ||
// for mainnet: const network = new StacksMainnet(); | ||
// the stacks STX address | ||
const address = 'ST3XKKN4RPV69NN1PHFDNX3TYKXT7XPC4N8KC1ARH'; | ||
const client = new StackingClient(address, network); | ||
``` | ||
// the stacks STX address | ||
const address = 'ST3XKKN4RPV69NN1PHFDNX3TYKXT7XPC4N8KC1ARH'; | ||
## Check stacking eligibility | ||
```typescript | ||
// a BTC address for reward payouts | ||
@@ -35,13 +37,4 @@ const poxAddress = 'mvuYDknzDtPgGqm2GnbAbmGMLwiyW3AwFP'; | ||
const cycles = 3; | ||
// how much to stack, in microSTX | ||
const amountMicroStx = new BN(100000000000); | ||
// private key for transaction signing | ||
const privateKey = 'd48f215481c16cbe6426f8e557df9b78895661971d71735126545abddcd5377001'; | ||
// block height at which to stack | ||
const burnBlockHeight = 2000; | ||
``` | ||
## Check stacking eligibility | ||
```typescript | ||
// Refer to initialization section to create client instance | ||
const stackingEligibility = await client.canStack({ poxAddress, cycles }); | ||
@@ -58,2 +51,14 @@ | ||
```typescript | ||
// a BTC address for reward payouts | ||
const poxAddress = 'mvuYDknzDtPgGqm2GnbAbmGMLwiyW3AwFP'; | ||
// number cycles to stack | ||
const cycles = 3; | ||
// how much to stack, in microSTX | ||
const amountMicroStx = 100000000000n; | ||
// private key for transaction signing | ||
const privateKey = 'd48f215481c16cbe6426f8e557df9b78895661971d71735126545abddcd5377001'; | ||
// block height at which to stack | ||
const burnBlockHeight = 2000; | ||
// Refer to initialization section to create client instance | ||
const stackingResults = await client.stack({ | ||
@@ -146,3 +151,3 @@ amountMicroStx, | ||
```js | ||
```typescript | ||
const hasMinStxAmount = await client.hasMinimumStx(); | ||
@@ -188,4 +193,8 @@ | ||
const untilBurnBlockHeight = 5000; | ||
// how much to stack, in microSTX | ||
const amountMicroStx = 100000000000n; | ||
// private key for transaction signing | ||
const privateKey = 'd48f215481c16cbe6426f8e557df9b78895661971d71735126545abddcd5377001'; | ||
const delegetateResponse = await client.delegateStx({ | ||
const delegetateResponse = await client.delegateStx({ | ||
amountMicroStx, | ||
@@ -205,3 +214,5 @@ delegateTo, | ||
```typescript | ||
// note that the parameter here is not JSON | ||
// private key for transaction signing | ||
const privateKey = 'd48f215481c16cbe6426f8e557df9b78895661971d71735126545abddcd5377001'; | ||
const revokeResponse = await client.revokeDelegateStx(privateKey); | ||
@@ -221,2 +232,10 @@ | ||
```typescript | ||
import { getNonce } from '@stacks/transactions'; | ||
import { StacksTestnet, StacksMainnet } from '@stacks/network'; | ||
import { StackingClient } from '@stacks/stacking'; | ||
// for mainnet: const network = new StacksMainnet(); | ||
const network = new StacksTestnet(); | ||
// the stacks STX address | ||
const address = 'ST3XKKN4RPV69NN1PHFDNX3TYKXT7XPC4N8KC1ARH'; | ||
// delegators would initiate a different client | ||
@@ -228,6 +247,11 @@ const delegatorAddress = 'ST22X605P0QX2BJC3NXEENXDPFCNJPHE02DTX5V74'; | ||
const delegatorBtcAddress = 'msiYwJCvXEzjgq6hDwD9ueBka6MTfN962Z'; | ||
// how much to stack, in microSTX | ||
const amountMicroStx = 100000000000n; | ||
// block height at which to stack | ||
const burnBlockHeight = 2000; | ||
// number cycles to stack | ||
const cycles = 3; | ||
// if you call this method multiple times in the same block, you need to increase the nonce manually | ||
let nonce = getNonce(delegatorAddress, network); | ||
nonce = nonce.add(new BN(1)); | ||
let nonce = await getNonce(delegatorAddress, network); | ||
nonce = nonce + 1n; | ||
@@ -256,2 +280,6 @@ const delegatorClient = new StackingClient(delegatorAddress, network); | ||
const rewardCycle = 12; | ||
// the BTC address for reward payouts | ||
const delegatorBtcAddress = 'msiYwJCvXEzjgq6hDwD9ueBka6MTfN962Z'; | ||
// Private key | ||
const privateKeyDelegate = 'd48f215481c16cbe6426f8e557df9b78895661971d71735126545abddcd5377001'; | ||
@@ -268,1 +296,94 @@ const delegetateCommitResponse = await delegatorClient.stackAggregationCommit({ | ||
``` | ||
#### Get burnchain rewards | ||
```typescript | ||
import { StacksTestnet, StacksMainnet } from '@stacks/network'; | ||
import { StackingClient } from '@stacks/stacking'; | ||
const address = 'myfTfju9XSMRusaY2qTitSEMSchsWRA441'; | ||
// for mainnet: const network = new StacksMainnet(); | ||
const network = new StacksTestnet(); | ||
const client = new StackingClient(address, network); | ||
const options = { limit: 2, offset: 0 }; | ||
const rewards = await client.getRewardsForBtcAddress(options); | ||
//{ | ||
// limit: 2, | ||
// offset: 0, | ||
// results: [ | ||
// { | ||
// canonical: true, | ||
// burn_block_hash: '0x000000000000002083ca8303a2262d09a824cecb34b78f13a04787e4f05441d3', | ||
// burn_block_height: 2004622, | ||
// burn_amount: '0', | ||
// reward_recipient: 'myfTfju9XSMRusaY2qTitSEMSchsWRA441', | ||
// reward_amount: '20000', | ||
// reward_index: 0 | ||
// }, | ||
// { | ||
// canonical: true, | ||
// burn_block_hash: '0x000000000000002f72213de621f9daf60d76aed3902a811561d06373b2fa6123', | ||
// burn_block_height: 2004621, | ||
// burn_amount: '0', | ||
// reward_recipient: 'myfTfju9XSMRusaY2qTitSEMSchsWRA441', | ||
// reward_amount: '20000', | ||
// reward_index: 0 | ||
// } | ||
// ] | ||
// }; | ||
``` | ||
#### Get burnchain rewards total | ||
```typescript | ||
import { StacksTestnet, StacksMainnet } from '@stacks/network'; | ||
import { StackingClient } from '@stacks/stacking'; | ||
const address = 'myfTfju9XSMRusaY2qTitSEMSchsWRA441'; | ||
// for mainnet: const network = new StacksMainnet(); | ||
const network = new StacksTestnet(); | ||
const client = new StackingClient(address, network); | ||
const total = await client.getRewardsTotalForBtcAddress(); | ||
//{ | ||
// reward_recipient: 'myfTfju9XSMRusaY2qTitSEMSchsWRA441', | ||
// reward_amount: '0' | ||
//} | ||
``` | ||
#### Get burnchain reward holders | ||
```typescript | ||
import { StacksTestnet, StacksMainnet } from '@stacks/network'; | ||
import { StackingClient } from '@stacks/stacking'; | ||
const address = 'myfTfju9XSMRusaY2qTitSEMSchsWRA441'; | ||
// for mainnet: const network = new StacksMainnet(); | ||
const network = new StacksTestnet(); | ||
const client = new StackingClient(address, network); | ||
const options = { limit: 2, offset: 0 }; | ||
const rewardHolders = await client.getRewardHoldersForBtcAddress(options); | ||
// { | ||
// limit: 2, | ||
// offset: 0, | ||
// total: 46, | ||
// results: [ | ||
// { | ||
// canonical: true, | ||
// burn_block_hash: '0x000000000000002083ca8303a2262d09a824cecb34b78f13a04787e4f05441d3', | ||
// burn_block_height: 2004622, | ||
// address: 'myfTfju9XSMRusaY2qTitSEMSchsWRA441', | ||
// slot_index: 1 | ||
// }, | ||
// { | ||
// canonical: true, | ||
// burn_block_hash: '0x000000000000002083ca8303a2262d09a824cecb34b78f13a04787e4f05441d3', | ||
// burn_block_height: 2004622, | ||
// address: 'myfTfju9XSMRusaY2qTitSEMSchsWRA441', | ||
// slot_index: 0 | ||
// } | ||
// ] | ||
// }; | ||
``` |
@@ -25,2 +25,3 @@ import { Buffer, IntegerType, intToBigInt } from '@stacks/common'; | ||
AnchorMode, | ||
getFee, | ||
} from '@stacks/transactions'; | ||
@@ -752,3 +753,3 @@ import { | ||
modifyLockTxFee({ tx, amountMicroStx }: { tx: StacksTransaction; amountMicroStx: IntegerType }) { | ||
const fee = tx.auth.getFee(); | ||
const fee = getFee(tx.auth); | ||
(tx.payload as ContractCallPayload).functionArgs[0] = uintCV( | ||
@@ -755,0 +756,0 @@ intToBigInt(amountMicroStx, false) - fee |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
146496
2413
0
0
379
- Removed@stacks/common@1.2.2(transitive)
- Removed@stacks/network@1.2.2(transitive)
Updated@stacks/common@^3.0.0
Updated@stacks/network@^3.0.0
Updated@stacks/transactions@^3.0.0