@harmony-js/staking
Advanced tools
Comparing version 0.1.55 to 0.1.56
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
/** | ||
* # @harmony-js/staking | ||
This package provides a collection of apis to create, sign/send staking transaction, and receive confirm/receipt. | ||
## Installation | ||
``` | ||
npm install @harmony-js/staking | ||
``` | ||
## Usage | ||
Create a Harmony instance connecting to testnet | ||
```javascript | ||
* const { Harmony } = require('@harmony-js/core'); | ||
* const { | ||
* ChainID, | ||
* ChainType, | ||
* hexToNumber, | ||
* numberToHex, | ||
* fromWei, | ||
* Units, | ||
* Unit, | ||
* } = require('@harmony-js/utils'); | ||
* const hmy = new Harmony( | ||
* 'https://api.s0.b.hmny.io/', | ||
* { | ||
* chainType: ChainType.Harmony, | ||
* chainId: ChainID.HmyTestnet, | ||
* }, | ||
* ); | ||
``` | ||
Below, examples show how to send delegate, undelegate, and collect rewards staking transactions. First, set the chainId, gasLimit, gasPrice for all subsequent staking transactions | ||
```javascript | ||
* hmy.stakings.setTxParams({ | ||
* gasLimit: 25000, | ||
* gasPrice: numberToHex(new hmy.utils.Unit('1').asGwei().toWei()), | ||
* chainId: 2 | ||
* }); | ||
``` | ||
<span style="color:red">Note: create and edit validator transactions are not fully supported in the sdk</span> | ||
Create delegate staking transaction | ||
```javascript | ||
* const delegate = hmy.stakings.delegate({ | ||
* delegatorAddress: 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7', | ||
* validatorAddress: 'one1vfqqagdzz352mtvdl69v0hw953hm993n6v26yl', | ||
* amount: numberToHex(new Unit(1000).asOne().toWei()) | ||
* }); | ||
* const delegateStakingTx = delegate.build(); | ||
``` | ||
Sign and send the delegate transaction and receive confirmation | ||
```javascript | ||
* // key corresponds to one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7, only has testnet balance | ||
* hmy.wallet.addByPrivateKey('45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e'); | ||
* hmy.wallet.signStaking(delegateStakingTx).then(signedTxn => { | ||
* signedTxn.sendTransaction().then(([tx, hash]) => { | ||
* console.log(hash); | ||
* signedTxn.confirm(hash).then(response => { | ||
* console.log(response.receipt); | ||
* }); | ||
* }); | ||
* }); | ||
``` | ||
Similarily, undelegate and collect reward transactions can be composed, signed and sent | ||
Create undelegate staking transaction | ||
```javascript | ||
* const undelegate = hmy.stakings.undelegate({ | ||
* delegatorAddress: 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7', | ||
* validatorAddress: 'one1vfqqagdzz352mtvdl69v0hw953hm993n6v26yl', | ||
* amount: numberToHex(new Unit(1000).asOne().toWei()) | ||
* }); | ||
* const undelegateStakingTx = undelegate.build(); | ||
``` | ||
Create collect rewards staking transaction | ||
```javascript | ||
* const collectRewards = hmy.stakings.collectRewards({ | ||
* delegatorAddress: 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7' | ||
* }); | ||
* const collectRewardsStakingTx = collectRewards.build(); | ||
``` | ||
Also, similar to normal transaction, signing and sending can be performed asynchronously. | ||
* @packageDocumentation | ||
@@ -3,0 +92,0 @@ * @module harmony-staking |
"use strict"; | ||
/** | ||
* # @harmony-js/staking | ||
This package provides a collection of apis to create, sign/send staking transaction, and receive confirm/receipt. | ||
## Installation | ||
``` | ||
npm install @harmony-js/staking | ||
``` | ||
## Usage | ||
Create a Harmony instance connecting to testnet | ||
```javascript | ||
* const { Harmony } = require('@harmony-js/core'); | ||
* const { | ||
* ChainID, | ||
* ChainType, | ||
* hexToNumber, | ||
* numberToHex, | ||
* fromWei, | ||
* Units, | ||
* Unit, | ||
* } = require('@harmony-js/utils'); | ||
* const hmy = new Harmony( | ||
* 'https://api.s0.b.hmny.io/', | ||
* { | ||
* chainType: ChainType.Harmony, | ||
* chainId: ChainID.HmyTestnet, | ||
* }, | ||
* ); | ||
``` | ||
Below, examples show how to send delegate, undelegate, and collect rewards staking transactions. First, set the chainId, gasLimit, gasPrice for all subsequent staking transactions | ||
```javascript | ||
* hmy.stakings.setTxParams({ | ||
* gasLimit: 25000, | ||
* gasPrice: numberToHex(new hmy.utils.Unit('1').asGwei().toWei()), | ||
* chainId: 2 | ||
* }); | ||
``` | ||
<span style="color:red">Note: create and edit validator transactions are not fully supported in the sdk</span> | ||
Create delegate staking transaction | ||
```javascript | ||
* const delegate = hmy.stakings.delegate({ | ||
* delegatorAddress: 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7', | ||
* validatorAddress: 'one1vfqqagdzz352mtvdl69v0hw953hm993n6v26yl', | ||
* amount: numberToHex(new Unit(1000).asOne().toWei()) | ||
* }); | ||
* const delegateStakingTx = delegate.build(); | ||
``` | ||
Sign and send the delegate transaction and receive confirmation | ||
```javascript | ||
* // key corresponds to one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7, only has testnet balance | ||
* hmy.wallet.addByPrivateKey('45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e'); | ||
* hmy.wallet.signStaking(delegateStakingTx).then(signedTxn => { | ||
* signedTxn.sendTransaction().then(([tx, hash]) => { | ||
* console.log(hash); | ||
* signedTxn.confirm(hash).then(response => { | ||
* console.log(response.receipt); | ||
* }); | ||
* }); | ||
* }); | ||
``` | ||
Similarily, undelegate and collect reward transactions can be composed, signed and sent | ||
Create undelegate staking transaction | ||
```javascript | ||
* const undelegate = hmy.stakings.undelegate({ | ||
* delegatorAddress: 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7', | ||
* validatorAddress: 'one1vfqqagdzz352mtvdl69v0hw953hm993n6v26yl', | ||
* amount: numberToHex(new Unit(1000).asOne().toWei()) | ||
* }); | ||
* const undelegateStakingTx = undelegate.build(); | ||
``` | ||
Create collect rewards staking transaction | ||
```javascript | ||
* const collectRewards = hmy.stakings.collectRewards({ | ||
* delegatorAddress: 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7' | ||
* }); | ||
* const collectRewardsStakingTx = collectRewards.build(); | ||
``` | ||
Also, similar to normal transaction, signing and sending can be performed asynchronously. | ||
* @packageDocumentation | ||
@@ -4,0 +93,0 @@ * @module harmony-staking |
{ | ||
"name": "@harmony-js/staking", | ||
"version": "0.1.55", | ||
"version": "0.1.56", | ||
"description": "staking transaction package for harmony", | ||
@@ -21,9 +21,9 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@harmony-js/crypto": "0.1.55", | ||
"@harmony-js/network": "0.1.55", | ||
"@harmony-js/transaction": "0.1.55", | ||
"@harmony-js/utils": "0.1.55", | ||
"@harmony-js/crypto": "0.1.56", | ||
"@harmony-js/network": "0.1.56", | ||
"@harmony-js/transaction": "0.1.56", | ||
"@harmony-js/utils": "0.1.56", | ||
"text-encoding": "^0.7.0" | ||
}, | ||
"gitHead": "c49abc56916e6edf7aa959e38397ff280e47ec30" | ||
"gitHead": "8f8e17fdaed394af1c28cd133d6018bf48915a81" | ||
} |
/** | ||
* # @harmony-js/staking | ||
This package provides a collection of apis to create, sign/send staking transaction, and receive confirm/receipt. | ||
## Installation | ||
``` | ||
npm install @harmony-js/staking | ||
``` | ||
## Usage | ||
Create a Harmony instance connecting to testnet | ||
```javascript | ||
* const { Harmony } = require('@harmony-js/core'); | ||
* const { | ||
* ChainID, | ||
* ChainType, | ||
* hexToNumber, | ||
* numberToHex, | ||
* fromWei, | ||
* Units, | ||
* Unit, | ||
* } = require('@harmony-js/utils'); | ||
* const hmy = new Harmony( | ||
* 'https://api.s0.b.hmny.io/', | ||
* { | ||
* chainType: ChainType.Harmony, | ||
* chainId: ChainID.HmyTestnet, | ||
* }, | ||
* ); | ||
``` | ||
Below, examples show how to send delegate, undelegate, and collect rewards staking transactions. First, set the chainId, gasLimit, gasPrice for all subsequent staking transactions | ||
```javascript | ||
* hmy.stakings.setTxParams({ | ||
* gasLimit: 25000, | ||
* gasPrice: numberToHex(new hmy.utils.Unit('1').asGwei().toWei()), | ||
* chainId: 2 | ||
* }); | ||
``` | ||
<span style="color:red">Note: create and edit validator transactions are not fully supported in the sdk</span> | ||
Create delegate staking transaction | ||
```javascript | ||
* const delegate = hmy.stakings.delegate({ | ||
* delegatorAddress: 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7', | ||
* validatorAddress: 'one1vfqqagdzz352mtvdl69v0hw953hm993n6v26yl', | ||
* amount: numberToHex(new Unit(1000).asOne().toWei()) | ||
* }); | ||
* const delegateStakingTx = delegate.build(); | ||
``` | ||
Sign and send the delegate transaction and receive confirmation | ||
```javascript | ||
* // key corresponds to one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7, only has testnet balance | ||
* hmy.wallet.addByPrivateKey('45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e'); | ||
* hmy.wallet.signStaking(delegateStakingTx).then(signedTxn => { | ||
* signedTxn.sendTransaction().then(([tx, hash]) => { | ||
* console.log(hash); | ||
* signedTxn.confirm(hash).then(response => { | ||
* console.log(response.receipt); | ||
* }); | ||
* }); | ||
* }); | ||
``` | ||
Similarily, undelegate and collect reward transactions can be composed, signed and sent | ||
Create undelegate staking transaction | ||
```javascript | ||
* const undelegate = hmy.stakings.undelegate({ | ||
* delegatorAddress: 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7', | ||
* validatorAddress: 'one1vfqqagdzz352mtvdl69v0hw953hm993n6v26yl', | ||
* amount: numberToHex(new Unit(1000).asOne().toWei()) | ||
* }); | ||
* const undelegateStakingTx = undelegate.build(); | ||
``` | ||
Create collect rewards staking transaction | ||
```javascript | ||
* const collectRewards = hmy.stakings.collectRewards({ | ||
* delegatorAddress: 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7' | ||
* }); | ||
* const collectRewardsStakingTx = collectRewards.build(); | ||
``` | ||
Also, similar to normal transaction, signing and sending can be performed asynchronously. | ||
* @packageDocumentation | ||
@@ -3,0 +92,0 @@ * @module harmony-staking |
@@ -325,7 +325,2 @@ /** | ||
id: 1, | ||
result: '0x666666666666', | ||
}, | ||
{ | ||
jsonrpc: '2.0', | ||
id: 1, | ||
result: testTx.nonce, | ||
@@ -376,7 +371,2 @@ }, | ||
id: 1, | ||
result: '0x666666666666', | ||
}, | ||
{ | ||
jsonrpc: '2.0', | ||
id: 1, | ||
result: testTx.nonce, | ||
@@ -422,7 +412,2 @@ }, | ||
id: 1, | ||
result: '0x666666666666', | ||
}, | ||
{ | ||
jsonrpc: '2.0', | ||
id: 1, | ||
result: testTx.nonce, | ||
@@ -459,7 +444,2 @@ }, | ||
id: 1, | ||
result: '0x666666666666', | ||
}, | ||
{ | ||
jsonrpc: '2.0', | ||
id: 1, | ||
result: testTx.nonce, | ||
@@ -497,7 +477,2 @@ }, | ||
id: 1, | ||
result: '0x666666666666', | ||
}, | ||
{ | ||
jsonrpc: '2.0', | ||
id: 1, | ||
result: testTx.nonce, | ||
@@ -504,0 +479,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
101919
23
2112
+ Added@harmony-js/crypto@0.1.56(transitive)
+ Added@harmony-js/network@0.1.56(transitive)
+ Added@harmony-js/transaction@0.1.56(transitive)
+ Added@harmony-js/utils@0.1.56(transitive)
+ Added@types/node@22.10.0(transitive)
+ Addedundici-types@6.20.0(transitive)
- Removed@harmony-js/crypto@0.1.55(transitive)
- Removed@harmony-js/network@0.1.55(transitive)
- Removed@harmony-js/transaction@0.1.55(transitive)
- Removed@harmony-js/utils@0.1.55(transitive)
- Removed@types/node@22.9.1(transitive)
- Removedundici-types@6.19.8(transitive)
Updated@harmony-js/crypto@0.1.56
Updated@harmony-js/network@0.1.56
Updated@harmony-js/utils@0.1.56