commit
4261bc15bb
@ -1,5 +0,0 @@ |
||||
GENESIS_PRIV_KEY=45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e |
||||
HTTP_PROVIDER=http://localhost:9500 |
||||
CHAIN_TYPE=hmy |
||||
CHAIN_ID=2 |
||||
|
@ -1,5 +0,0 @@ |
||||
GENESIS_PRIV_KEY=45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e |
||||
HTTP_PROVIDER=http://localhost:9500 |
||||
CHAIN_TYPE=hmy |
||||
CHAIN_ID=2 |
||||
|
@ -1,134 +0,0 @@ |
||||
# Quick start |
||||
|
||||
1. You need Harmony local testnet running. |
||||
instruction here:[harmony-one/harmony](https://github.com/harmony-one/harmony) |
||||
2. Run this example under nodejs enviorment. |
||||
|
||||
```javascript |
||||
// import or require Harmony class |
||||
const { Harmony } = require('@harmony-js/core'); |
||||
|
||||
// import or require settings |
||||
const { ChainID, ChainType } = require('@harmony-js/utils'); |
||||
|
||||
// 1. initialize the Harmony instance |
||||
|
||||
const harmony = new Harmony( |
||||
// rpc url |
||||
'http://localhost:9500', |
||||
{ |
||||
// chainType set to Harmony |
||||
chainType: ChainType.Harmony, |
||||
// chainType set to HmyLocal |
||||
chainId: ChainID.HmyLocal, |
||||
}, |
||||
); |
||||
|
||||
// 2. get wallet ready |
||||
// specify the privateKey |
||||
const privateKey = '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e'; |
||||
// add privateKey to wallet |
||||
const sender = harmony.wallet.addByPrivateKey(privateKey); |
||||
|
||||
// 3. get sharding info |
||||
async function setSharding() { |
||||
// Harmony is a sharded blockchain, each endpoint have sharding structure, |
||||
// However sharding structure is different between mainnet, testnet and local testnet |
||||
// We need to get sharding info before doing cross-shard transaction |
||||
const res = await harmony.blockchain.getShardingStructure(); |
||||
harmony.shardingStructures(res.result); |
||||
} |
||||
|
||||
// 4. get transaction payload ready |
||||
|
||||
async function transfer() { |
||||
// run set sharding first, if you want to make a cross-shard transaction |
||||
await setSharding(); |
||||
|
||||
const txn = harmony.transactions.newTx({ |
||||
// token send to |
||||
to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2', |
||||
// amount to send |
||||
value: '10000', |
||||
// gas limit, you can use string |
||||
gasLimit: '210000', |
||||
// send token from shardID |
||||
shardID: 0, |
||||
// send token to toShardID |
||||
toShardID: 0, |
||||
// gas Price, you can use Unit class, and use Gwei, then remember to use toWei(), which will be transformed to BN |
||||
gasPrice: new harmony.utils.Unit('100').asGwei().toWei(), |
||||
}); |
||||
|
||||
// sign the transaction use wallet; |
||||
|
||||
const signedTxn = await harmony.wallet.signTransaction(txn); |
||||
|
||||
// Now you can use `Transaction.observed()` to listen events |
||||
|
||||
signedTxn |
||||
.observed() |
||||
.on('transactionHash', (txnHash) => { |
||||
console.log(''); |
||||
console.log('--- hash ---'); |
||||
console.log(''); |
||||
console.log(txnHash); |
||||
console.log(''); |
||||
}) |
||||
.on('receipt', (receipt) => { |
||||
console.log(''); |
||||
console.log('--- receipt ---'); |
||||
console.log(''); |
||||
console.log(receipt); |
||||
console.log(''); |
||||
}) |
||||
.on('cxReceipt', (receipt) => { |
||||
console.log(''); |
||||
console.log('--- cxReceipt ---'); |
||||
console.log(''); |
||||
console.log(receipt); |
||||
console.log(''); |
||||
}) |
||||
.on('error', (error) => { |
||||
console.log(''); |
||||
console.log('--- error ---'); |
||||
console.log(''); |
||||
console.log(error); |
||||
console.log(''); |
||||
}); |
||||
|
||||
// send the txn, get [Transaction, transactionHash] as result |
||||
|
||||
const [sentTxn, txnHash] = await signedTxn.sendTransaction(); |
||||
|
||||
// to confirm the result if it is already there |
||||
|
||||
const confiremdTxn = await sentTxn.confirm(txnHash); |
||||
|
||||
// if the transactino is cross-shard transaction |
||||
if (!confiremdTxn.isCrossShard()) { |
||||
if (confiremdTxn.isConfirmed()) { |
||||
console.log('--- Result ---'); |
||||
console.log(''); |
||||
console.log('Normal transaction'); |
||||
console.log(`${txnHash} is confirmed`); |
||||
console.log(''); |
||||
process.exit(); |
||||
} |
||||
} |
||||
if (confiremdTxn.isConfirmed() && confiremdTxn.isCxConfirmed()) { |
||||
console.log('--- Result ---'); |
||||
console.log(''); |
||||
console.log('Cross-Shard transaction'); |
||||
console.log(`${txnHash} is confirmed`); |
||||
console.log(''); |
||||
process.exit(); |
||||
} |
||||
} |
||||
|
||||
transfer(); |
||||
``` |
||||
|
||||
# More examples |
||||
|
||||
* [dapp-examples](https://github.com/harmony-one/dapp-examples) |
@ -1,31 +0,0 @@ |
||||
const { Harmony } = require('@harmony-js/core'); |
||||
|
||||
// import or require settings
|
||||
const { ChainID, ChainType } = require('@harmony-js/utils'); |
||||
|
||||
const URL_TESTNET = `https://api.s0.b.hmny.io`; |
||||
const URL_MAINNET = `https://api.s0.t.hmny.io`; |
||||
|
||||
// 1. initialize the Harmony instance
|
||||
|
||||
const harmony = new Harmony( |
||||
// rpc url
|
||||
URL_TESTNET, |
||||
{ |
||||
// chainType set to Harmony
|
||||
chainType: ChainType.Harmony, |
||||
// chainType set to HmyLocal
|
||||
chainId: ChainID.HmyTestnet, |
||||
}, |
||||
); |
||||
|
||||
harmony.blockchain |
||||
.getBalance({ |
||||
address: `one1vjywuur8ckddmc4dsyx6qdgf590eu07ag9fg4a`, |
||||
}) |
||||
.then((res) => { |
||||
console.log(new harmony.utils.Unit(res.result).asWei().toEther()); |
||||
}) |
||||
.catch((err) => { |
||||
console.log(err); |
||||
}); |
@ -1,45 +0,0 @@ |
||||
// import the Account class
|
||||
const { Account } = require('@harmony-js/account'); |
||||
|
||||
// suppose we have an account
|
||||
const myPrivateKey = '0x831f0b3ff835d5ec4602878742fda25591b6d3bb2731366621ac83a05216bec8'; |
||||
const myAccountWithMyPrivateKey = new Account(myPrivateKey); |
||||
|
||||
// suppose we have a password, and we want to encrypt the account above
|
||||
const myStrongPassword = '123'; |
||||
|
||||
async function encryptAndDecrypt(password) { |
||||
// we get the privateKey before encrypted as comparison
|
||||
const unencryptedPrivateKey = myAccountWithMyPrivateKey.privateKey; |
||||
|
||||
// export the account to keyStore string, which will make the privateKey encrpyted
|
||||
const keyStoreFile = await myAccountWithMyPrivateKey.toFile(password); |
||||
// exported keyStoreFile
|
||||
console.log({ keyStoreFile }); |
||||
// see if the account is encrypted
|
||||
console.log(`Is this account encrypted? \n ${myAccountWithMyPrivateKey.encrypted}`); |
||||
// keystore file should be equal to encrypted privateKey
|
||||
console.log( |
||||
`Is privateKey equal to keyStore string? \n ${keyStoreFile === |
||||
myAccountWithMyPrivateKey.privateKey}`,
|
||||
); |
||||
} |
||||
|
||||
encryptAndDecrypt(myStrongPassword); |
||||
|
||||
// suppose we have keyStorefile, in this example, we just use same password and keystore string encrypted above
|
||||
const someKeyStoreFile = |
||||
'{"version":3,"id":"38326265-6165-4961-a338-353063643962","address":"1cc87010760602a576455d6d2f03a3bf92d2c2ca","crypto":{"ciphertext":"a4ee9120b27ba66fb9d3fabd6372fa3a11060cf439a6a1777ced1e6253de8c29","cipherparams":{"iv":"c18772a882ac461fffd1971e9ec57861"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"salt":"da4efedeca407279be65e02fc94b7c4b7c74c3396447c71e659c74a73a5d9131","n":8192,"r":8,"p":1,"dklen":32},"mac":"547ee6616dcdf424273c113ceb00728ccdda17ff6449f2cb84a1a8352c87b4e6"}}'; |
||||
|
||||
async function importKeyStoreFileAndDecrypt(keyStoreFile, password) { |
||||
// import keyStore string and provide the password, remember to make a new Account first
|
||||
const importedAccount = await Account.new().fromFile(keyStoreFile, password); |
||||
// the account should decypted which `Account.encrypted` is false
|
||||
console.log(`Is this account encrypted? \n ${importedAccount.encrypted}`); |
||||
// see if the privatekey is equal to unencrypted one?
|
||||
console.log( |
||||
`Is the account recovered from keystore? \n ${importedAccount.privateKey === myPrivateKey}`, |
||||
); |
||||
} |
||||
|
||||
importKeyStoreFileAndDecrypt(someKeyStoreFile, myStrongPassword); |
@ -1,597 +0,0 @@ |
||||
{ |
||||
"name": "example", |
||||
"version": "1.0.0", |
||||
"lockfileVersion": 1, |
||||
"requires": true, |
||||
"dependencies": { |
||||
"@harmony-js/account": { |
||||
"version": "0.1.43", |
||||
"resolved": "https://registry.npmjs.org/@harmony-js/account/-/account-0.1.43.tgz", |
||||
"integrity": "sha512-+sY6p64y4R4oSJNcVjdBQ9BL+KlrIeuBB+tIH0lDwXyKXb4dmJbjPNjVO088OBW0CsFOXnDU/zkOC4BSdBKWOw==", |
||||
"requires": { |
||||
"@harmony-js/core": "^0.1.43", |
||||
"@harmony-js/crypto": "^0.1.43", |
||||
"@harmony-js/network": "^0.1.43", |
||||
"@harmony-js/staking": "^0.1.43", |
||||
"@harmony-js/transaction": "^0.1.43", |
||||
"@harmony-js/utils": "^0.1.43" |
||||
} |
||||
}, |
||||
"@harmony-js/contract": { |
||||
"version": "0.1.43", |
||||
"resolved": "https://registry.npmjs.org/@harmony-js/contract/-/contract-0.1.43.tgz", |
||||
"integrity": "sha512-PjoLIr+AkID07c0NWk9yv19ovol7r/s42acm8IEibUVg7TffxQRyuIyxtkUHcemOX5cT53DVVuLhW3vSByIf9A==", |
||||
"requires": { |
||||
"@harmony-js/account": "^0.1.43", |
||||
"@harmony-js/crypto": "^0.1.43", |
||||
"@harmony-js/network": "^0.1.43", |
||||
"@harmony-js/transaction": "^0.1.43", |
||||
"@harmony-js/utils": "^0.1.43" |
||||
} |
||||
}, |
||||
"@harmony-js/core": { |
||||
"version": "0.1.43", |
||||
"resolved": "https://registry.npmjs.org/@harmony-js/core/-/core-0.1.43.tgz", |
||||
"integrity": "sha512-0dx3bt9nZ2U81gVWZfw11iO+tdsrQbiSFff3clbL73uJblyBv+Vy6OMSA3VIgEwpv0+I9fhqK7wiK2SADJE++Q==", |
||||
"requires": { |
||||
"@harmony-js/account": "^0.1.43", |
||||
"@harmony-js/contract": "^0.1.43", |
||||
"@harmony-js/crypto": "^0.1.43", |
||||
"@harmony-js/network": "^0.1.43", |
||||
"@harmony-js/staking": "^0.1.43", |
||||
"@harmony-js/transaction": "^0.1.43", |
||||
"@harmony-js/utils": "^0.1.43" |
||||
} |
||||
}, |
||||
"@harmony-js/crypto": { |
||||
"version": "0.1.43", |
||||
"resolved": "https://registry.npmjs.org/@harmony-js/crypto/-/crypto-0.1.43.tgz", |
||||
"integrity": "sha512-YNvRXXhfvqmvKeZXZUe+O38pCphSHa6GKddUlKYXUqzAkGddnwN/OjPxQfn9gVw/56eyWy1dojTDa08zBboLqA==", |
||||
"requires": { |
||||
"@harmony-js/utils": "^0.1.43", |
||||
"aes-js": "^3.1.2", |
||||
"bip39": "^2.5.0", |
||||
"bn.js": "^4.11.8", |
||||
"elliptic": "^6.4.1", |
||||
"hdkey": "^1.1.1", |
||||
"hmac-drbg": "^1.0.1", |
||||
"js-sha3": "^0.8.0", |
||||
"pbkdf2": "^3.0.17", |
||||
"scrypt-shim": "github:web3-js/scrypt-shim", |
||||
"uuid": "^3.3.2" |
||||
} |
||||
}, |
||||
"@harmony-js/network": { |
||||
"version": "0.1.43", |
||||
"resolved": "https://registry.npmjs.org/@harmony-js/network/-/network-0.1.43.tgz", |
||||
"integrity": "sha512-ElfcLX0h4saMJo1VJzsPPFNznURFmOLSiHTvaEPUWjdUTBGw0jaeH+VwrodL8MkHcSGnWgcRxrDEan+cX1cznQ==", |
||||
"requires": { |
||||
"@harmony-js/utils": "^0.1.43", |
||||
"cross-fetch": "^3.0.2", |
||||
"mitt": "^1.2.0", |
||||
"websocket": "^1.0.28" |
||||
} |
||||
}, |
||||
"@harmony-js/staking": { |
||||
"version": "0.1.43", |
||||
"resolved": "https://registry.npmjs.org/@harmony-js/staking/-/staking-0.1.43.tgz", |
||||
"integrity": "sha512-XnIUT4V/Aj1AmVTM/X41gSHzHR6Ngh5mh1u8nVzDxJIkzW5Act0UdIEdfLOgnAWBwPhIeS37oxyy1+LfzcpDsA==", |
||||
"requires": { |
||||
"@harmony-js/crypto": "^0.1.43", |
||||
"@harmony-js/network": "^0.1.43", |
||||
"@harmony-js/transaction": "^0.1.43", |
||||
"@harmony-js/utils": "^0.1.43", |
||||
"text-encoding": "^0.7.0" |
||||
} |
||||
}, |
||||
"@harmony-js/transaction": { |
||||
"version": "0.1.43", |
||||
"resolved": "https://registry.npmjs.org/@harmony-js/transaction/-/transaction-0.1.43.tgz", |
||||
"integrity": "sha512-oVxMhJSzgj249m2L4PMfS9qt7MW9jLp8/H59lQVEwzy0dVWWZi1cHnHrgMZJA6FbG4WeDIScrVl6K6kBdsQFTg==", |
||||
"requires": { |
||||
"@harmony-js/crypto": "^0.1.43", |
||||
"@harmony-js/network": "^0.1.43", |
||||
"@harmony-js/utils": "^0.1.43" |
||||
} |
||||
}, |
||||
"@harmony-js/utils": { |
||||
"version": "0.1.43", |
||||
"resolved": "https://registry.npmjs.org/@harmony-js/utils/-/utils-0.1.43.tgz", |
||||
"integrity": "sha512-6WFvw4JK3tEuGHAk2EeYZMWcxjveIcBhnP9B0a2N+GK3rWBotjkWAD/w8eWaK03q6LbNeenAQDVOCmE6JY7v1A==", |
||||
"requires": { |
||||
"@types/bn.js": "^4.11.3", |
||||
"bn.js": "^4.11.8" |
||||
} |
||||
}, |
||||
"@types/bn.js": { |
||||
"version": "4.11.6", |
||||
"resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-4.11.6.tgz", |
||||
"integrity": "sha512-pqr857jrp2kPuO9uRjZ3PwnJTjoQy+fcdxvBTvHm6dkmEL9q+hDD/2j/0ELOBPtPnS8LjCX0gI9nbl8lVkadpg==", |
||||
"requires": { |
||||
"@types/node": "*" |
||||
} |
||||
}, |
||||
"@types/node": { |
||||
"version": "14.0.9", |
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.9.tgz", |
||||
"integrity": "sha512-0sCTiXKXELOBxvZLN4krQ0FPOAA7ij+6WwvD0k/PHd9/KAkr4dXel5J9fh6F4x1FwAQILqAWkmpeuS6mjf1iKA==" |
||||
}, |
||||
"aes-js": { |
||||
"version": "3.1.2", |
||||
"resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.1.2.tgz", |
||||
"integrity": "sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ==" |
||||
}, |
||||
"base-x": { |
||||
"version": "3.0.8", |
||||
"resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.8.tgz", |
||||
"integrity": "sha512-Rl/1AWP4J/zRrk54hhlxH4drNxPJXYUaKffODVI53/dAsV4t9fBxyxYKAVPU1XBHxYwOWP9h9H0hM2MVw4YfJA==", |
||||
"requires": { |
||||
"safe-buffer": "^5.0.1" |
||||
} |
||||
}, |
||||
"bindings": { |
||||
"version": "1.5.0", |
||||
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", |
||||
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", |
||||
"requires": { |
||||
"file-uri-to-path": "1.0.0" |
||||
} |
||||
}, |
||||
"bip39": { |
||||
"version": "2.6.0", |
||||
"resolved": "https://registry.npmjs.org/bip39/-/bip39-2.6.0.tgz", |
||||
"integrity": "sha512-RrnQRG2EgEoqO24ea+Q/fftuPUZLmrEM3qNhhGsA3PbaXaCW791LTzPuVyx/VprXQcTbPJ3K3UeTna8ZnVl2sg==", |
||||
"requires": { |
||||
"create-hash": "^1.1.0", |
||||
"pbkdf2": "^3.0.9", |
||||
"randombytes": "^2.0.1", |
||||
"safe-buffer": "^5.0.1", |
||||
"unorm": "^1.3.3" |
||||
} |
||||
}, |
||||
"bip66": { |
||||
"version": "1.1.5", |
||||
"resolved": "https://registry.npmjs.org/bip66/-/bip66-1.1.5.tgz", |
||||
"integrity": "sha1-AfqHSHhcpwlV1QESF9GzE5lpyiI=", |
||||
"requires": { |
||||
"safe-buffer": "^5.0.1" |
||||
} |
||||
}, |
||||
"bn.js": { |
||||
"version": "4.11.9", |
||||
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.9.tgz", |
||||
"integrity": "sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw==" |
||||
}, |
||||
"brorand": { |
||||
"version": "1.1.0", |
||||
"resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", |
||||
"integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=" |
||||
}, |
||||
"browserify-aes": { |
||||
"version": "1.2.0", |
||||
"resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", |
||||
"integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", |
||||
"requires": { |
||||
"buffer-xor": "^1.0.3", |
||||
"cipher-base": "^1.0.0", |
||||
"create-hash": "^1.1.0", |
||||
"evp_bytestokey": "^1.0.3", |
||||
"inherits": "^2.0.1", |
||||
"safe-buffer": "^5.0.1" |
||||
} |
||||
}, |
||||
"bs58": { |
||||
"version": "4.0.1", |
||||
"resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", |
||||
"integrity": "sha1-vhYedsNU9veIrkBx9j806MTwpCo=", |
||||
"requires": { |
||||
"base-x": "^3.0.2" |
||||
} |
||||
}, |
||||
"bs58check": { |
||||
"version": "2.1.2", |
||||
"resolved": "https://registry.npmjs.org/bs58check/-/bs58check-2.1.2.tgz", |
||||
"integrity": "sha512-0TS1jicxdU09dwJMNZtVAfzPi6Q6QeN0pM1Fkzrjn+XYHvzMKPU3pHVpva+769iNVSfIYWf7LJ6WR+BuuMf8cA==", |
||||
"requires": { |
||||
"bs58": "^4.0.0", |
||||
"create-hash": "^1.1.0", |
||||
"safe-buffer": "^5.1.2" |
||||
} |
||||
}, |
||||
"buffer-xor": { |
||||
"version": "1.0.3", |
||||
"resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", |
||||
"integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=" |
||||
}, |
||||
"cipher-base": { |
||||
"version": "1.0.4", |
||||
"resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", |
||||
"integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", |
||||
"requires": { |
||||
"inherits": "^2.0.1", |
||||
"safe-buffer": "^5.0.1" |
||||
} |
||||
}, |
||||
"create-hash": { |
||||
"version": "1.2.0", |
||||
"resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", |
||||
"integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", |
||||
"requires": { |
||||
"cipher-base": "^1.0.1", |
||||
"inherits": "^2.0.1", |
||||
"md5.js": "^1.3.4", |
||||
"ripemd160": "^2.0.1", |
||||
"sha.js": "^2.4.0" |
||||
} |
||||
}, |
||||
"create-hmac": { |
||||
"version": "1.1.7", |
||||
"resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", |
||||
"integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", |
||||
"requires": { |
||||
"cipher-base": "^1.0.3", |
||||
"create-hash": "^1.1.0", |
||||
"inherits": "^2.0.1", |
||||
"ripemd160": "^2.0.0", |
||||
"safe-buffer": "^5.0.1", |
||||
"sha.js": "^2.4.8" |
||||
} |
||||
}, |
||||
"cross-fetch": { |
||||
"version": "3.0.4", |
||||
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.0.4.tgz", |
||||
"integrity": "sha512-MSHgpjQqgbT/94D4CyADeNoYh52zMkCX4pcJvPP5WqPsLFMKjr2TCMg381ox5qI0ii2dPwaLx/00477knXqXVw==", |
||||
"requires": { |
||||
"node-fetch": "2.6.0", |
||||
"whatwg-fetch": "3.0.0" |
||||
} |
||||
}, |
||||
"d": { |
||||
"version": "1.0.1", |
||||
"resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", |
||||
"integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==", |
||||
"requires": { |
||||
"es5-ext": "^0.10.50", |
||||
"type": "^1.0.1" |
||||
} |
||||
}, |
||||
"debug": { |
||||
"version": "2.6.9", |
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", |
||||
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", |
||||
"requires": { |
||||
"ms": "2.0.0" |
||||
} |
||||
}, |
||||
"drbg.js": { |
||||
"version": "1.0.1", |
||||
"resolved": "https://registry.npmjs.org/drbg.js/-/drbg.js-1.0.1.tgz", |
||||
"integrity": "sha1-Pja2xCs3BDgjzbwzLVjzHiRFSAs=", |
||||
"requires": { |
||||
"browserify-aes": "^1.0.6", |
||||
"create-hash": "^1.1.2", |
||||
"create-hmac": "^1.1.4" |
||||
} |
||||
}, |
||||
"elliptic": { |
||||
"version": "6.5.3", |
||||
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz", |
||||
"integrity": "sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==", |
||||
"requires": { |
||||
"bn.js": "^4.4.0", |
||||
"brorand": "^1.0.1", |
||||
"hash.js": "^1.0.0", |
||||
"hmac-drbg": "^1.0.0", |
||||
"inherits": "^2.0.1", |
||||
"minimalistic-assert": "^1.0.0", |
||||
"minimalistic-crypto-utils": "^1.0.0" |
||||
} |
||||
}, |
||||
"es5-ext": { |
||||
"version": "0.10.53", |
||||
"resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.53.tgz", |
||||
"integrity": "sha512-Xs2Stw6NiNHWypzRTY1MtaG/uJlwCk8kH81920ma8mvN8Xq1gsfhZvpkImLQArw8AHnv8MT2I45J3c0R8slE+Q==", |
||||
"requires": { |
||||
"es6-iterator": "~2.0.3", |
||||
"es6-symbol": "~3.1.3", |
||||
"next-tick": "~1.0.0" |
||||
} |
||||
}, |
||||
"es6-iterator": { |
||||
"version": "2.0.3", |
||||
"resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", |
||||
"integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=", |
||||
"requires": { |
||||
"d": "1", |
||||
"es5-ext": "^0.10.35", |
||||
"es6-symbol": "^3.1.1" |
||||
} |
||||
}, |
||||
"es6-symbol": { |
||||
"version": "3.1.3", |
||||
"resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz", |
||||
"integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==", |
||||
"requires": { |
||||
"d": "^1.0.1", |
||||
"ext": "^1.1.2" |
||||
} |
||||
}, |
||||
"evp_bytestokey": { |
||||
"version": "1.0.3", |
||||
"resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", |
||||
"integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", |
||||
"requires": { |
||||
"md5.js": "^1.3.4", |
||||
"safe-buffer": "^5.1.1" |
||||
} |
||||
}, |
||||
"ext": { |
||||
"version": "1.4.0", |
||||
"resolved": "https://registry.npmjs.org/ext/-/ext-1.4.0.tgz", |
||||
"integrity": "sha512-Key5NIsUxdqKg3vIsdw9dSuXpPCQ297y6wBjL30edxwPgt2E44WcWBZey/ZvUc6sERLTxKdyCu4gZFmUbk1Q7A==", |
||||
"requires": { |
||||
"type": "^2.0.0" |
||||
}, |
||||
"dependencies": { |
||||
"type": { |
||||
"version": "2.0.0", |
||||
"resolved": "https://registry.npmjs.org/type/-/type-2.0.0.tgz", |
||||
"integrity": "sha512-KBt58xCHry4Cejnc2ISQAF7QY+ORngsWfxezO68+12hKV6lQY8P/psIkcbjeHWn7MqcgciWJyCCevFMJdIXpow==" |
||||
} |
||||
} |
||||
}, |
||||
"file-uri-to-path": { |
||||
"version": "1.0.0", |
||||
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", |
||||
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" |
||||
}, |
||||
"hash-base": { |
||||
"version": "3.1.0", |
||||
"resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.1.0.tgz", |
||||
"integrity": "sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA==", |
||||
"requires": { |
||||
"inherits": "^2.0.4", |
||||
"readable-stream": "^3.6.0", |
||||
"safe-buffer": "^5.2.0" |
||||
} |
||||
}, |
||||
"hash.js": { |
||||
"version": "1.1.7", |
||||
"resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", |
||||
"integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", |
||||
"requires": { |
||||
"inherits": "^2.0.3", |
||||
"minimalistic-assert": "^1.0.1" |
||||
} |
||||
}, |
||||
"hdkey": { |
||||
"version": "1.1.2", |
||||
"resolved": "https://registry.npmjs.org/hdkey/-/hdkey-1.1.2.tgz", |
||||
"integrity": "sha512-PTQ4VKu0oRnCrYfLp04iQZ7T2Cxz0UsEXYauk2j8eh6PJXCpbXuCFhOmtIFtbET0i3PMWmHN9J11gU8LEgUljQ==", |
||||
"requires": { |
||||
"bs58check": "^2.1.2", |
||||
"safe-buffer": "^5.1.1", |
||||
"secp256k1": "^3.0.1" |
||||
} |
||||
}, |
||||
"hmac-drbg": { |
||||
"version": "1.0.1", |
||||
"resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", |
||||
"integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", |
||||
"requires": { |
||||
"hash.js": "^1.0.3", |
||||
"minimalistic-assert": "^1.0.0", |
||||
"minimalistic-crypto-utils": "^1.0.1" |
||||
} |
||||
}, |
||||
"inherits": { |
||||
"version": "2.0.4", |
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", |
||||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" |
||||
}, |
||||
"is-typedarray": { |
||||
"version": "1.0.0", |
||||
"resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", |
||||
"integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" |
||||
}, |
||||
"js-sha3": { |
||||
"version": "0.8.0", |
||||
"resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz", |
||||
"integrity": "sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==" |
||||
}, |
||||
"md5.js": { |
||||
"version": "1.3.5", |
||||
"resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", |
||||
"integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", |
||||
"requires": { |
||||
"hash-base": "^3.0.0", |
||||
"inherits": "^2.0.1", |
||||
"safe-buffer": "^5.1.2" |
||||
} |
||||
}, |
||||
"minimalistic-assert": { |
||||
"version": "1.0.1", |
||||
"resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", |
||||
"integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==" |
||||
}, |
||||
"minimalistic-crypto-utils": { |
||||
"version": "1.0.1", |
||||
"resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", |
||||
"integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=" |
||||
}, |
||||
"mitt": { |
||||
"version": "1.2.0", |
||||
"resolved": "https://registry.npmjs.org/mitt/-/mitt-1.2.0.tgz", |
||||
"integrity": "sha512-r6lj77KlwqLhIUku9UWYes7KJtsczvolZkzp8hbaDPPaE24OmWl5s539Mytlj22siEQKosZ26qCBgda2PKwoJw==" |
||||
}, |
||||
"ms": { |
||||
"version": "2.0.0", |
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", |
||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" |
||||
}, |
||||
"nan": { |
||||
"version": "2.14.1", |
||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.14.1.tgz", |
||||
"integrity": "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw==" |
||||
}, |
||||
"next-tick": { |
||||
"version": "1.0.0", |
||||
"resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", |
||||
"integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=" |
||||
}, |
||||
"node-fetch": { |
||||
"version": "2.6.0", |
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", |
||||
"integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" |
||||
}, |
||||
"pbkdf2": { |
||||
"version": "3.0.17", |
||||
"resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz", |
||||
"integrity": "sha512-U/il5MsrZp7mGg3mSQfn742na2T+1/vHDCG5/iTI3X9MKUuYUZVLQhyRsg06mCgDBTd57TxzgZt7P+fYfjRLtA==", |
||||
"requires": { |
||||
"create-hash": "^1.1.2", |
||||
"create-hmac": "^1.1.4", |
||||
"ripemd160": "^2.0.1", |
||||
"safe-buffer": "^5.0.1", |
||||
"sha.js": "^2.4.8" |
||||
} |
||||
}, |
||||
"randombytes": { |
||||
"version": "2.1.0", |
||||
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", |
||||
"integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", |
||||
"requires": { |
||||
"safe-buffer": "^5.1.0" |
||||
} |
||||
}, |
||||
"readable-stream": { |
||||
"version": "3.6.0", |
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", |
||||
"integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", |
||||
"requires": { |
||||
"inherits": "^2.0.3", |
||||
"string_decoder": "^1.1.1", |
||||
"util-deprecate": "^1.0.1" |
||||
} |
||||
}, |
||||
"ripemd160": { |
||||
"version": "2.0.2", |
||||
"resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", |
||||
"integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", |
||||
"requires": { |
||||
"hash-base": "^3.0.0", |
||||
"inherits": "^2.0.1" |
||||
} |
||||
}, |
||||
"safe-buffer": { |
||||
"version": "5.2.1", |
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", |
||||
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" |
||||
}, |
||||
"scrypt-shim": { |
||||
"version": "github:web3-js/scrypt-shim#aafdadda13e660e25e1c525d1f5b2443f5eb1ebb", |
||||
"from": "github:web3-js/scrypt-shim", |
||||
"requires": { |
||||
"scryptsy": "^2.1.0", |
||||
"semver": "^6.3.0" |
||||
} |
||||
}, |
||||
"scryptsy": { |
||||
"version": "2.1.0", |
||||
"resolved": "https://registry.npmjs.org/scryptsy/-/scryptsy-2.1.0.tgz", |
||||
"integrity": "sha512-1CdSqHQowJBnMAFyPEBRfqag/YP9OF394FV+4YREIJX4ljD7OxvQRDayyoyyCk+senRjSkP6VnUNQmVQqB6g7w==" |
||||
}, |
||||
"secp256k1": { |
||||
"version": "3.8.0", |
||||
"resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-3.8.0.tgz", |
||||
"integrity": "sha512-k5ke5avRZbtl9Tqx/SA7CbY3NF6Ro+Sj9cZxezFzuBlLDmyqPiL8hJJ+EmzD8Ig4LUDByHJ3/iPOVoRixs/hmw==", |
||||
"requires": { |
||||
"bindings": "^1.5.0", |
||||
"bip66": "^1.1.5", |
||||
"bn.js": "^4.11.8", |
||||
"create-hash": "^1.2.0", |
||||
"drbg.js": "^1.0.1", |
||||
"elliptic": "^6.5.2", |
||||
"nan": "^2.14.0", |
||||
"safe-buffer": "^5.1.2" |
||||
} |
||||
}, |
||||
"semver": { |
||||
"version": "6.3.0", |
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", |
||||
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==" |
||||
}, |
||||
"sha.js": { |
||||
"version": "2.4.11", |
||||
"resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", |
||||
"integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", |
||||
"requires": { |
||||
"inherits": "^2.0.1", |
||||
"safe-buffer": "^5.0.1" |
||||
} |
||||
}, |
||||
"string_decoder": { |
||||
"version": "1.3.0", |
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", |
||||
"integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", |
||||
"requires": { |
||||
"safe-buffer": "~5.2.0" |
||||
} |
||||
}, |
||||
"text-encoding": { |
||||
"version": "0.7.0", |
||||
"resolved": "https://registry.npmjs.org/text-encoding/-/text-encoding-0.7.0.tgz", |
||||
"integrity": "sha512-oJQ3f1hrOnbRLOcwKz0Liq2IcrvDeZRHXhd9RgLrsT+DjWY/nty1Hi7v3dtkaEYbPYe0mUoOfzRrMwfXXwgPUA==" |
||||
}, |
||||
"type": { |
||||
"version": "1.2.0", |
||||
"resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", |
||||
"integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==" |
||||
}, |
||||
"typedarray-to-buffer": { |
||||
"version": "3.1.5", |
||||
"resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", |
||||
"integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", |
||||
"requires": { |
||||
"is-typedarray": "^1.0.0" |
||||
} |
||||
}, |
||||
"unorm": { |
||||
"version": "1.6.0", |
||||
"resolved": "https://registry.npmjs.org/unorm/-/unorm-1.6.0.tgz", |
||||
"integrity": "sha512-b2/KCUlYZUeA7JFUuRJZPUtr4gZvBh7tavtv4fvk4+KV9pfGiR6CQAQAWl49ZpR3ts2dk4FYkP7EIgDJoiOLDA==" |
||||
}, |
||||
"util-deprecate": { |
||||
"version": "1.0.2", |
||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", |
||||
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" |
||||
}, |
||||
"uuid": { |
||||
"version": "3.4.0", |
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", |
||||
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==" |
||||
}, |
||||
"websocket": { |
||||
"version": "1.0.31", |
||||
"resolved": "https://registry.npmjs.org/websocket/-/websocket-1.0.31.tgz", |
||||
"integrity": "sha512-VAouplvGKPiKFDTeCCO65vYHsyay8DqoBSlzIO3fayrfOgU94lQN5a1uWVnFrMLceTJw/+fQXR5PGbUVRaHshQ==", |
||||
"requires": { |
||||
"debug": "^2.2.0", |
||||
"es5-ext": "^0.10.50", |
||||
"nan": "^2.14.0", |
||||
"typedarray-to-buffer": "^3.1.5", |
||||
"yaeti": "^0.0.6" |
||||
} |
||||
}, |
||||
"whatwg-fetch": { |
||||
"version": "3.0.0", |
||||
"resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz", |
||||
"integrity": "sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q==" |
||||
}, |
||||
"yaeti": { |
||||
"version": "0.0.6", |
||||
"resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz", |
||||
"integrity": "sha1-8m9ITXJoTPQr7ft2lwqhYI+/lXc=" |
||||
} |
||||
} |
||||
} |
@ -1,14 +0,0 @@ |
||||
{ |
||||
"name": "example", |
||||
"version": "1.0.0", |
||||
"description": "", |
||||
"main": "test.js", |
||||
"scripts": { |
||||
"test": "echo \"Error: no test specified\" && exit 1" |
||||
}, |
||||
"author": "", |
||||
"license": "ISC", |
||||
"dependencies": { |
||||
"@harmony-js/core": "^0.1.41" |
||||
} |
||||
} |
@ -1,79 +0,0 @@ |
||||
const { Harmony } = require('@harmony-js/core'); |
||||
const { ChainID, ChainType } = require('@harmony-js/utils'); |
||||
const { |
||||
StakingTransaction, |
||||
CreateValidator, |
||||
Delegate, |
||||
Undelegate, |
||||
CollectRewards, |
||||
StakingFactory, |
||||
} = require('@harmony-js/staking'); |
||||
|
||||
const harmony = new Harmony('http://localhost:9500', { |
||||
chainId: ChainID.HmyLocal, |
||||
chainType: ChainType.Harmony, |
||||
}); |
||||
|
||||
const stakingTxn = harmony.stakings |
||||
.createValidator({ |
||||
validatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9', |
||||
description: { |
||||
name: 'Alice', |
||||
identity: 'alice', |
||||
website: 'alice.harmony.one', |
||||
securityContact: 'Bob', |
||||
details: "Don't mess with me!!!", |
||||
}, |
||||
commissionRate: { |
||||
rate: '0.1', |
||||
maxRate: '0.9', |
||||
maxChangeRate: '0.05', |
||||
}, |
||||
minSelfDelegation: '0xa', |
||||
maxTotalDelegation: '0x0bb8', |
||||
slotPubKeys: [ |
||||
'0xb9486167ab9087ab818dc4ce026edb5bf216863364c32e42df2af03c5ced1ad181e7d12f0e6dd5307a73b62247608611', |
||||
], |
||||
amount: '0x64', |
||||
}) |
||||
.setTxParams({ |
||||
nonce: '0x2', |
||||
gasPrice: '0x', |
||||
gasLimit: '0x64', |
||||
chainId: 0, |
||||
}) |
||||
.build(); |
||||
|
||||
stakingTxn |
||||
.sendTransaction() |
||||
.then(([stakingTxn, res]) => { |
||||
console.log(res); |
||||
}) |
||||
.catch((err) => { |
||||
console.log(err); |
||||
}); |
||||
|
||||
// const delegateMsg = Delegate({
|
||||
// delegatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
|
||||
// validatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
|
||||
// amount: '0xa',
|
||||
// });
|
||||
|
||||
// const stakingTxn = StakingTransaction({
|
||||
// directive: '0x2',
|
||||
// stakeMsg: delegateMsg,
|
||||
// nonce: '0x2',
|
||||
// gasPrice: '0x',
|
||||
// gasLimit: '0x64',
|
||||
// chainId: 0,
|
||||
// from: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
|
||||
// });
|
||||
|
||||
// stakingTxn
|
||||
// .sendTransaction()
|
||||
// .then((stakingTxn, res) => {
|
||||
// console.log(res);
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// console.log(err);
|
||||
// });
|
@ -1,172 +0,0 @@ |
||||
const { Harmony } = require('@harmony-js/core'); |
||||
const { ChainID, ChainType } = require('@harmony-js/utils'); |
||||
const { Delegate, StakingTransaction, StakingFactory } = require('@harmony-js/staking'); //../packages/harmony-staking
|
||||
const { TxStatus } = require('@harmony-js/transaction'); |
||||
|
||||
const LOCALNET = `http://localhost:9500`; |
||||
|
||||
// 1. initialize the Harmony instance
|
||||
|
||||
const harmony = new Harmony( |
||||
// rpc url
|
||||
LOCALNET, |
||||
{ |
||||
// chainType set to Harmony
|
||||
chainType: ChainType.Harmony, |
||||
// chainType set to HmyLocal
|
||||
chainId: ChainID.HmyLocal, |
||||
}, |
||||
); |
||||
|
||||
// 2. get wallet ready
|
||||
|
||||
// one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
|
||||
// surge welcome lion goose gate consider taste injury health march debris kick
|
||||
|
||||
// add privateKey to wallet
|
||||
const private = '63e35b761e9df0d50ddcdaa8e33c235b60c991bfed22925a12768b0c08ef822f'; |
||||
// one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy
|
||||
const sender = harmony.wallet.addByPrivateKey(private); |
||||
console.log(sender.address); |
||||
// const phrase =
|
||||
// 'genius cable radar memory high catch blossom correct middle wish gentle
|
||||
// fiscal';
|
||||
|
||||
// one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
|
||||
// surge welcome lion goose gate consider taste injury health march debris kick
|
||||
|
||||
// add privateKey to wallet
|
||||
// const sender = harmony.wallet.addByMnemonic(phrase);
|
||||
// let r =
|
||||
// '0xf8f180f8a4940b585f8daefbc68a311fbd4cb20d9174ad174016f83885416c69636585616c69636591616c6963652e6861726d6f6e792e6f6e6583426f6295446f6e2774206d6573732077697468206d65212121ddc988016345785d8a0000c9880c7d713b49da0000c887b1a2bc2ec500000a820bb8f1b0b9486167ab9087ab818dc4ce026edb5bf216863364c32e42df2af03c5ced1ad181e7d12f0e6dd5307a73b6224760861164008080830927c028a064b1b835f5b70a72228920db24e44c0a57d954c1d3dcac3b33c79d9593f96191a05577fd05064a37043a33ff7febb67ab126a8e1f0b67c92b7cab793a87ddf2c82';
|
||||
|
||||
// const delegateMsg = new Delegate(
|
||||
// 'one1pf75h0t4am90z8uv3y0dgunfqp4lj8wr3t5rsp', // from delegate command.
|
||||
// 'one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy', // fd416cb87dcf8ed187e85545d7734a192fc8e976f5b540e9e21e896ec2bc25c3
|
||||
// '0xde0b6b3a7640000', // 0x56BC75E2D63100000
|
||||
// );
|
||||
|
||||
// // one12fuf7x9rgtdgqg7vgq0962c556m3p7afsxgvll;
|
||||
|
||||
// const stakingTxn = new StakingTransaction(
|
||||
// '0x2',
|
||||
// delegateMsg,
|
||||
// '0x2',
|
||||
// '0x',
|
||||
// '0x0927c0',
|
||||
// ChainID.HmyLocal,
|
||||
// );
|
||||
|
||||
const stakingTxn = harmony.stakings |
||||
.delegate({ |
||||
delegatorAddress: 'one1pf75h0t4am90z8uv3y0dgunfqp4lj8wr3t5rsp', |
||||
validatorAddress: 'one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy', |
||||
amount: '0xde0b6b3a7640000', |
||||
}) |
||||
.setTxParams({ nonce: '0x2', gasPrice: '0x', gasLimit: '0x0927c0', chainId: ChainID.HmyLocal }) |
||||
.build(); |
||||
|
||||
// 3. get sharding info
|
||||
async function setSharding() { |
||||
// Harmony is a sharded blockchain, each endpoint have sharding structure,
|
||||
// However sharding structure is different between mainnet, testnet and local
|
||||
// testnet We need to get sharding info before doing cross-shard transaction
|
||||
const res = await harmony.blockchain.getShardingStructure(); |
||||
harmony.shardingStructures(res.result); |
||||
} |
||||
|
||||
async function execute() { |
||||
await setSharding(); |
||||
|
||||
const signedTxn = await harmony.wallet.signStaking(stakingTxn); |
||||
signedTxn |
||||
.observed() |
||||
.on('transactionHash', (txnHash) => { |
||||
console.log(''); |
||||
console.log('--- hash ---'); |
||||
console.log(''); |
||||
console.log(txnHash); |
||||
console.log(''); |
||||
}) |
||||
.on('receipt', (receipt) => { |
||||
console.log(''); |
||||
console.log('--- receipt ---'); |
||||
console.log(''); |
||||
console.log(receipt); |
||||
console.log(''); |
||||
}) |
||||
.on('cxReceipt', (receipt) => { |
||||
console.log(''); |
||||
console.log('--- cxReceipt ---'); |
||||
console.log(''); |
||||
console.log(receipt); |
||||
console.log(''); |
||||
}) |
||||
.on('error', (error) => { |
||||
console.log(''); |
||||
console.log('--- error ---'); |
||||
console.log(''); |
||||
console.log(error); |
||||
console.log(''); |
||||
}); |
||||
|
||||
// console.log(signedTxn);
|
||||
|
||||
const [sentTxn, txnHash] = await signedTxn.sendTransaction(); |
||||
// signedTxn.sendTransaction()
|
||||
// .then(res => {
|
||||
// console.log(res);
|
||||
// })
|
||||
// .catch(err => {
|
||||
// console.log(err);
|
||||
// });
|
||||
|
||||
// to confirm the result if it is already there
|
||||
// console.log(txnHash);
|
||||
console.log(sentTxn); |
||||
|
||||
const confiremdTxn = await sentTxn.confirm(txnHash); |
||||
|
||||
// if the transactino is cross-shard transaction
|
||||
if (confiremdTxn.isConfirmed()) { |
||||
console.log('--- Result ---'); |
||||
console.log(''); |
||||
console.log('Normal transaction'); |
||||
console.log(`${txnHash} is confirmed`); |
||||
console.log(''); |
||||
process.exit(); |
||||
} |
||||
// if (confiremdTxn.isConfirmed() && confiremdTxn.isCxConfirmed()) {
|
||||
// console.log('--- Result ---');
|
||||
// console.log('');
|
||||
// console.log('Cross-Shard transaction');
|
||||
// console.log(`${txnHash} is confirmed`);
|
||||
// console.log('');
|
||||
// process.exit();
|
||||
// }
|
||||
} |
||||
execute(); |
||||
// const delegateMsg = Delegate({
|
||||
// delegatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
|
||||
// validatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
|
||||
// amount: '0xa',
|
||||
// });
|
||||
|
||||
// const stakingTxn = StakingTransaction({
|
||||
// directive: '0x2',
|
||||
// stakeMsg: delegateMsg,
|
||||
// nonce: '0x2',
|
||||
// gasPrice: '0x',
|
||||
// gasLimit: '0x64',
|
||||
// chainId: 0,
|
||||
// from: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
|
||||
// });
|
||||
|
||||
// stakingTxn
|
||||
// .sendTransaction()
|
||||
// .then((stakingTxn, res) => {
|
||||
// console.log(res);
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// console.log(err);
|
||||
// });
|
@ -1,74 +0,0 @@ |
||||
const { Harmony } = require('@harmony-js/core'); |
||||
const { ChainID, ChainType } = require('@harmony-js/utils'); |
||||
const { StakingFactory } = require('@harmony-js/staking'); |
||||
|
||||
const harmony = new Harmony('http://localhost:9500', { |
||||
chainId: ChainID.HmyLocal, |
||||
chainType: ChainType.Harmony, |
||||
}); |
||||
|
||||
const createMsg = { |
||||
validatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9', |
||||
description: { |
||||
name: 'Alice', |
||||
identity: 'alice', |
||||
website: 'alice.harmony.one', |
||||
securityContact: 'Bob', |
||||
details: "Don't mess with me!!!", |
||||
}, |
||||
commissionRate: { |
||||
rate: '0.1', |
||||
maxRate: '0.9', |
||||
maxChangeRate: '0.05', |
||||
}, |
||||
minSelfDelegation: '0xa', |
||||
maxTotalDelegation: '0x0bb8', |
||||
slotPubKeys: [ |
||||
'0xb9486167ab9087ab818dc4ce026edb5bf216863364c32e42df2af03c5ced1ad181e7d12f0e6dd5307a73b62247608611', |
||||
], |
||||
amount: '0x64', |
||||
}; |
||||
|
||||
const stakingTxn = harmony.stakings |
||||
.createValidator(createMsg) |
||||
.setTxParams({ |
||||
nonce: '0x2', |
||||
gasPrice: '0x', |
||||
gasLimit: '0x64', |
||||
chainId: 0, |
||||
}) |
||||
.build(); |
||||
|
||||
stakingTxn |
||||
.sendTransaction() |
||||
.then(([stakingTxn, res]) => { |
||||
console.log(res); |
||||
}) |
||||
.catch((err) => { |
||||
console.log(err); |
||||
}); |
||||
|
||||
// const delegateMsg = Delegate({
|
||||
// delegatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
|
||||
// validatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
|
||||
// amount: '0xa',
|
||||
// });
|
||||
|
||||
// const stakingTxn = StakingTransaction({
|
||||
// directive: '0x2',
|
||||
// stakeMsg: delegateMsg,
|
||||
// nonce: '0x2',
|
||||
// gasPrice: '0x',
|
||||
// gasLimit: '0x64',
|
||||
// chainId: 0,
|
||||
// from: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
|
||||
// });
|
||||
|
||||
// stakingTxn
|
||||
// .sendTransaction()
|
||||
// .then((stakingTxn, res) => {
|
||||
// console.log(res);
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// console.log(err);
|
||||
// });
|
@ -1,177 +0,0 @@ |
||||
const { Harmony } = require('@harmony-js/core'); |
||||
const { ChainID, ChainType } = require('@harmony-js/utils'); |
||||
const { |
||||
Description, |
||||
Decimal, |
||||
CommissionRate, |
||||
StakingTransaction, |
||||
CreateValidator, |
||||
} = require('@harmony-js/staking'); //../packages/harmony-staking
|
||||
const { TxStatus } = require('@harmony-js/transaction'); |
||||
|
||||
const LOCALNET = `http://localhost:9500`; |
||||
|
||||
// 1. initialize the Harmony instance
|
||||
|
||||
const harmony = new Harmony( |
||||
// rpc url
|
||||
LOCALNET, |
||||
{ |
||||
// chainType set to Harmony
|
||||
chainType: ChainType.Harmony, |
||||
// chainType set to HmyLocal
|
||||
chainId: ChainID.HmyLocal, |
||||
}, |
||||
); |
||||
|
||||
// 2. get wallet ready
|
||||
|
||||
// one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
|
||||
// surge welcome lion goose gate consider taste injury health march debris kick
|
||||
|
||||
// add privateKey to wallet
|
||||
const private = 'fd416cb87dcf8ed187e85545d7734a192fc8e976f5b540e9e21e896ec2bc25c3'; |
||||
const sender = harmony.wallet.addByPrivateKey(private); |
||||
// const phrase =
|
||||
// 'genius cable radar memory high catch blossom correct middle wish gentle
|
||||
// fiscal';
|
||||
|
||||
// one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
|
||||
// surge welcome lion goose gate consider taste injury health march debris kick
|
||||
|
||||
// add privateKey to wallet
|
||||
// const sender = harmony.wallet.addByMnemonic(phrase);
|
||||
|
||||
const stakingTxn = harmony.stakings |
||||
.createValidator({ |
||||
validatorAddress: 'one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy', |
||||
description: { |
||||
name: 'Alice', |
||||
identity: 'alice', |
||||
website: 'alice.harmony.one', |
||||
securityContact: 'Bob', |
||||
details: "Don't mess with me!!", |
||||
}, |
||||
commissionRate: { rate: '0.1', maxRate: '0.9', maxChangeRate: '0.05' }, |
||||
minSelfDelegation: '0x8AC7230489E80000', |
||||
maxTotalDelegation: '0xA2A15D09519BE00000', |
||||
slotPubKeys: [ |
||||
'0xb9486167ab9087ab818dc4ce026edb5bf216863364c32e42df2af03c5ced1ad181e7d12f0e6dd5307a73b62247608611', |
||||
], |
||||
amount: '0x56BC75E2D63100000', |
||||
}) |
||||
.setTxParams({ |
||||
nonce: '0x2', |
||||
gasPrice: '0x', |
||||
gasLimit: '0x0927c0', |
||||
chainId: ChainID.HmyLocal, |
||||
}) |
||||
.build(); |
||||
|
||||
// 3. get sharding info
|
||||
async function setSharding() { |
||||
// Harmony is a sharded blockchain, each endpoint have sharding structure,
|
||||
// However sharding structure is different between mainnet, testnet and local
|
||||
// testnet We need to get sharding info before doing cross-shard transaction
|
||||
const res = await harmony.blockchain.getShardingStructure(); |
||||
harmony.shardingStructures(res.result); |
||||
} |
||||
|
||||
async function execute() { |
||||
await setSharding(); |
||||
|
||||
const signedTxn = await harmony.wallet.signStaking(stakingTxn); |
||||
signedTxn |
||||
.observed() |
||||
.on('transactionHash', (txnHash) => { |
||||
console.log(''); |
||||
console.log('--- hash ---'); |
||||
console.log(''); |
||||
console.log(txnHash); |
||||
console.log(''); |
||||
}) |
||||
.on('receipt', (receipt) => { |
||||
console.log(''); |
||||
console.log('--- receipt ---'); |
||||
console.log(''); |
||||
console.log(receipt); |
||||
console.log(''); |
||||
}) |
||||
.on('cxReceipt', (receipt) => { |
||||
console.log(''); |
||||
console.log('--- cxReceipt ---'); |
||||
console.log(''); |
||||
console.log(receipt); |
||||
console.log(''); |
||||
}) |
||||
.on('error', (error) => { |
||||
console.log(''); |
||||
console.log('--- error ---'); |
||||
console.log(''); |
||||
console.log(error); |
||||
console.log(''); |
||||
}); |
||||
|
||||
// console.log(signedTxn);
|
||||
|
||||
const [sentTxn, txnHash] = await signedTxn.sendTransaction(); |
||||
// signedTxn
|
||||
// .sendTransaction()
|
||||
// .then((res) => {
|
||||
// console.log(res);
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// console.log(err);
|
||||
// });
|
||||
|
||||
// to confirm the result if it is already there
|
||||
console.log(txnHash); |
||||
console.log(sentTxn); |
||||
|
||||
const confiremdTxn = await sentTxn.confirm(txnHash); |
||||
|
||||
// if the transactino is cross-shard transaction
|
||||
// if (!confiremdTxn.isCrossShard()) {
|
||||
if (confiremdTxn.isConfirmed()) { |
||||
console.log('--- Result ---'); |
||||
console.log(''); |
||||
console.log('Staking transaction'); |
||||
console.log(`${txnHash} is confirmed`); |
||||
console.log(''); |
||||
process.exit(); |
||||
} |
||||
// }
|
||||
// if (confiremdTxn.isConfirmed() && confiremdTxn.isCxConfirmed()) {
|
||||
// console.log('--- Result ---');
|
||||
// console.log('');
|
||||
// console.log('Cross-Shard transaction');
|
||||
// console.log(`${txnHash} is confirmed`);
|
||||
// console.log('');
|
||||
// process.exit();
|
||||
// }
|
||||
} |
||||
execute(); |
||||
// const delegateMsg = Delegate({
|
||||
// delegatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
|
||||
// validatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
|
||||
// amount: '0xa',
|
||||
// });
|
||||
|
||||
// const stakingTxn = StakingTransaction({
|
||||
// directive: '0x2',
|
||||
// stakeMsg: delegateMsg,
|
||||
// nonce: '0x2',
|
||||
// gasPrice: '0x',
|
||||
// gasLimit: '0x64',
|
||||
// chainId: 0,
|
||||
// from: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
|
||||
// });
|
||||
|
||||
// stakingTxn
|
||||
// .sendTransaction()
|
||||
// .then((stakingTxn, res) => {
|
||||
// console.log(res);
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// console.log(err);
|
||||
// });
|
@ -1,173 +0,0 @@ |
||||
const { Harmony } = require('@harmony-js/core'); |
||||
const { ChainID, ChainType } = require('@harmony-js/utils'); |
||||
const { Undelegate, StakingTransaction, StakingFactory } = require('@harmony-js/staking'); //../packages/harmony-staking
|
||||
const { TxStatus } = require('@harmony-js/transaction'); |
||||
|
||||
const LOCALNET = `http://localhost:9500`; |
||||
|
||||
// 1. initialize the Harmony instance
|
||||
|
||||
const harmony = new Harmony( |
||||
// rpc url
|
||||
LOCALNET, |
||||
{ |
||||
// chainType set to Harmony
|
||||
chainType: ChainType.Harmony, |
||||
// chainType set to HmyLocal
|
||||
chainId: ChainID.HmyLocal, |
||||
}, |
||||
); |
||||
|
||||
// 2. get wallet ready
|
||||
|
||||
// one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
|
||||
// surge welcome lion goose gate consider taste injury health march debris kick
|
||||
|
||||
// add privateKey to wallet
|
||||
const private = '63e35b761e9df0d50ddcdaa8e33c235b60c991bfed22925a12768b0c08ef822f'; |
||||
const sender = harmony.wallet.addByPrivateKey(private); |
||||
// const phrase =
|
||||
// 'genius cable radar memory high catch blossom correct middle wish gentle
|
||||
// fiscal';
|
||||
|
||||
// one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
|
||||
// surge welcome lion goose gate consider taste injury health march debris kick
|
||||
|
||||
// add privateKey to wallet
|
||||
// const sender = harmony.wallet.addByMnemonic(phrase);
|
||||
// let r =
|
||||
// '0xf8f180f8a4940b585f8daefbc68a311fbd4cb20d9174ad174016f83885416c69636585616c69636591616c6963652e6861726d6f6e792e6f6e6583426f6295446f6e2774206d6573732077697468206d65212121ddc988016345785d8a0000c9880c7d713b49da0000c887b1a2bc2ec500000a820bb8f1b0b9486167ab9087ab818dc4ce026edb5bf216863364c32e42df2af03c5ced1ad181e7d12f0e6dd5307a73b6224760861164008080830927c028a064b1b835f5b70a72228920db24e44c0a57d954c1d3dcac3b33c79d9593f96191a05577fd05064a37043a33ff7febb67ab126a8e1f0b67c92b7cab793a87ddf2c82';
|
||||
|
||||
// const undelegateMsg = new Undelegate(
|
||||
// 'one1pf75h0t4am90z8uv3y0dgunfqp4lj8wr3t5rsp', // signed should match this
|
||||
// 'one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy',
|
||||
// '0x16345785d8a0000',
|
||||
// );
|
||||
|
||||
// const stakingTxn = new StakingTransaction(
|
||||
// '0x3',
|
||||
// undelegateMsg,
|
||||
// '0x2',
|
||||
// '0x',
|
||||
// '0x0927c0',
|
||||
// ChainID.HmyLocal,
|
||||
// );
|
||||
|
||||
const stakingTxn = harmony.stakings |
||||
.undelegate({ |
||||
delegatorAddress: 'one1pf75h0t4am90z8uv3y0dgunfqp4lj8wr3t5rsp', |
||||
validatorAddress: 'one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy', |
||||
amount: '0x16345785d8a0000', |
||||
}) |
||||
.setTxParams({ |
||||
nonce: '0x2', |
||||
gasPrice: '0x', |
||||
gasLimit: '0x0927c0', |
||||
chainId: ChainID.HmyLocal, |
||||
}) |
||||
.build(); |
||||
|
||||
// 3. get sharding info
|
||||
async function setSharding() { |
||||
// Harmony is a sharded blockchain, each endpoint have sharding structure,
|
||||
// However sharding structure is different between mainnet, testnet and local
|
||||
// testnet We need to get sharding info before doing cross-shard transaction
|
||||
const res = await harmony.blockchain.getShardingStructure(); |
||||
harmony.shardingStructures(res.result); |
||||
} |
||||
|
||||
async function execute() { |
||||
await setSharding(); |
||||
|
||||
const signedTxn = await harmony.wallet.signStaking(stakingTxn); |
||||
signedTxn |
||||
.observed() |
||||
.on('transactionHash', (txnHash) => { |
||||
console.log(''); |
||||
console.log('--- hash ---'); |
||||
console.log(''); |
||||
console.log(txnHash); |
||||
console.log(''); |
||||
}) |
||||
.on('receipt', (receipt) => { |
||||
console.log(''); |
||||
console.log('--- receipt ---'); |
||||
console.log(''); |
||||
console.log(receipt); |
||||
console.log(''); |
||||
}) |
||||
.on('cxReceipt', (receipt) => { |
||||
console.log(''); |
||||
console.log('--- cxReceipt ---'); |
||||
console.log(''); |
||||
console.log(receipt); |
||||
console.log(''); |
||||
}) |
||||
.on('error', (error) => { |
||||
console.log(''); |
||||
console.log('--- error ---'); |
||||
console.log(''); |
||||
console.log(error); |
||||
console.log(''); |
||||
}); |
||||
|
||||
// console.log(signedTxn);
|
||||
|
||||
const [sentTxn, txnHash] = await signedTxn.sendTransaction(); |
||||
// signedTxn.sendTransaction()
|
||||
// .then(res => {
|
||||
// console.log(res);
|
||||
// })
|
||||
// .catch(err => {
|
||||
// console.log(err);
|
||||
// });
|
||||
|
||||
// to confirm the result if it is already there
|
||||
// console.log(txnHash);
|
||||
console.log(sentTxn); |
||||
|
||||
const confiremdTxn = await sentTxn.confirm(txnHash); |
||||
|
||||
// if the transactino is cross-shard transaction
|
||||
if (confiremdTxn.isConfirmed()) { |
||||
console.log('--- Result ---'); |
||||
console.log(''); |
||||
console.log('Normal transaction'); |
||||
console.log(`${txnHash} is confirmed`); |
||||
console.log(''); |
||||
process.exit(); |
||||
} |
||||
// if (confiremdTxn.isConfirmed() && confiremdTxn.isCxConfirmed()) {
|
||||
// console.log('--- Result ---');
|
||||
// console.log('');
|
||||
// console.log('Cross-Shard transaction');
|
||||
// console.log(`${txnHash} is confirmed`);
|
||||
// console.log('');
|
||||
// process.exit();
|
||||
// }
|
||||
} |
||||
execute(); |
||||
// const delegateMsg = Delegate({
|
||||
// delegatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
|
||||
// validatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
|
||||
// amount: '0xa',
|
||||
// });
|
||||
|
||||
// const stakingTxn = StakingTransaction({
|
||||
// directive: '0x2',
|
||||
// stakeMsg: delegateMsg,
|
||||
// nonce: '0x2',
|
||||
// gasPrice: '0x',
|
||||
// gasLimit: '0x64',
|
||||
// chainId: 0,
|
||||
// from: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
|
||||
// });
|
||||
|
||||
// stakingTxn
|
||||
// .sendTransaction()
|
||||
// .then((stakingTxn, res) => {
|
||||
// console.log(res);
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// console.log(err);
|
||||
// });
|
@ -1,31 +0,0 @@ |
||||
const { Harmony } = require('@harmony-js/core'); |
||||
const { ChainID, ChainType } = require('@harmony-js/utils'); |
||||
const { encryptPhrase, decryptPhrase } = require('@harmony-js/crypto'); |
||||
|
||||
const harmony = new Harmony('http://localhost:9500', { chainId: 2, chainType: 'hmy' }); |
||||
const myPhrase = harmony.wallet.newMnemonic(); |
||||
const pwd = '1234'; |
||||
|
||||
async function encryptThePhrase(phrase, pass) { |
||||
const result = await encryptPhrase(phrase, pass); |
||||
return result; |
||||
} |
||||
|
||||
async function decryptThePhrase(keystore, pass) { |
||||
const result = await decryptPhrase(keystore, pass); |
||||
return result; |
||||
} |
||||
|
||||
async function phraseKeyStore() { |
||||
const keyStore = await encryptThePhrase(myPhrase, pwd); |
||||
const recoveredPhrase = await decryptThePhrase(JSON.parse(keyStore), pwd); |
||||
return { myPhrase, keyStore, recoveredPhrase }; |
||||
} |
||||
|
||||
phraseKeyStore().then((result) => { |
||||
const { myPhrase, keyStore, recoveredPhrase } = result; |
||||
|
||||
harmony.wallet.addByMnemonic(myPhrase); |
||||
console.log({ myPhrase, keyStore, recoveredPhrase }); |
||||
console.log(harmony.wallet); |
||||
}); |
@ -1,40 +0,0 @@ |
||||
const { Harmony } = require('@harmony-js/core'); |
||||
const { ChainID, ChainType } = require('@harmony-js/utils'); |
||||
const { |
||||
randomBytes, |
||||
generatePrivateKey, |
||||
getAddress, |
||||
getAddressFromPrivateKey, |
||||
encryptPhrase, |
||||
decryptPhrase, |
||||
} = require('@harmony-js/crypto'); |
||||
|
||||
const harmony = new Harmony('http://localhost:9500', { chainId: 2, chainType: 'hmy' }); |
||||
const myPhrase = harmony.wallet.newMnemonic(); |
||||
const pwd = '1234'; |
||||
|
||||
async function encryptThePhrase(phrase, pass) { |
||||
const result = await encryptPhrase(phrase, pass); |
||||
return result; |
||||
} |
||||
|
||||
async function decryptThePhrase(keystore, pass) { |
||||
const result = await decryptPhrase(keystore, pass); |
||||
return result; |
||||
} |
||||
|
||||
async function phraseKeyStore() { |
||||
const keyStore = await encryptThePhrase(myPhrase, pwd); |
||||
const recoveredPhrase = await decryptThePhrase(JSON.parse(keyStore), pwd); |
||||
return { myPhrase, keyStore, recoveredPhrase }; |
||||
} |
||||
|
||||
phraseKeyStore().then((result) => { |
||||
const { myPhrase, keyStore, recoveredPhrase } = result; |
||||
|
||||
const anotherPhrase = 'wall public vague under poem acid jaguar describe net scene sponsor neck'; |
||||
harmony.wallet.addByMnemonic(myPhrase); |
||||
harmony.wallet.addByMnemonic(anotherPhrase); |
||||
console.log({ myPhrase, keyStore, recoveredPhrase }); |
||||
console.log(harmony.wallet); |
||||
}); |
@ -1,153 +0,0 @@ |
||||
// import or require Harmony class
|
||||
const { Harmony } = require('@harmony-js/core'); |
||||
|
||||
// import or require settings
|
||||
const { ChainID, ChainType } = require('@harmony-js/utils'); |
||||
|
||||
const URL_TESTNET = `https://api.s0.b.hmny.io`; |
||||
const URL_MAINNET = `https://api.s0.t.hmny.io`; |
||||
const URL_PANGAEA = 'https://api.s0.pga.hmny.io'; |
||||
|
||||
// 1. initialize the Harmony instance
|
||||
|
||||
const harmony = new Harmony( |
||||
// rpc url
|
||||
URL_PANGAEA, |
||||
{ |
||||
// chainType set to Harmony
|
||||
chainType: ChainType.Harmony, |
||||
// chainType set to HmyLocal
|
||||
chainId: ChainID.HmyPangaea, |
||||
}, |
||||
); |
||||
|
||||
// 2. get wallet ready
|
||||
// one18n8e7472pg5fqvcfcr5hg0npquha24wsxmjheg
|
||||
const phrase = 'genius cable radar memory high catch blossom correct middle wish gentle fiscal'; |
||||
// const phrase =
|
||||
// 'resemble rent deposit unique garment ripple burst negative else decorate menu theme';
|
||||
|
||||
// one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
|
||||
// surge welcome lion goose gate consider taste injury health march debris kick
|
||||
|
||||
// add privateKey to wallet
|
||||
|
||||
const privateKey = '63e35b761e9df0d50ddcdaa8e33c235b60c991bfed22925a12768b0c08ef822f'; |
||||
|
||||
const sender = harmony.wallet.addByMnemonic(phrase); |
||||
const sender2 = harmony.wallet.addByPrivateKey(privateKey); |
||||
|
||||
harmony.wallet.setSigner(sender2.address); |
||||
|
||||
console.log('sender2Address is : ', sender2.bech32Address); |
||||
|
||||
// 3. get sharding info
|
||||
async function setSharding() { |
||||
// Harmony is a sharded blockchain, each endpoint have sharding structure,
|
||||
// However sharding structure is different between mainnet, testnet and local testnet
|
||||
// We need to get sharding info before doing cross-shard transaction
|
||||
const res = await harmony.blockchain.getShardingStructure(); |
||||
|
||||
harmony.shardingStructures(res.result); |
||||
} |
||||
|
||||
// 4. get transaction payload ready
|
||||
|
||||
async function transfer(receiver) { |
||||
// run set sharding first, if you want to make a cross-shard transaction
|
||||
await setSharding(); |
||||
|
||||
//1e18
|
||||
const txn = harmony.transactions.newTx({ |
||||
// token send to
|
||||
to: receiver, |
||||
// amount to send
|
||||
value: '100000000', |
||||
// gas limit, you can use string
|
||||
gasLimit: '210000', |
||||
// send token from shardID
|
||||
shardID: 0, |
||||
// send token to toShardID
|
||||
toShardID: 1, |
||||
// gas Price, you can use Unit class, and use Gwei, then remember to use toWei(), which will be transformed to BN
|
||||
gasPrice: new harmony.utils.Unit('10').asGwei().toWei(), |
||||
}); |
||||
|
||||
// sign the transaction use wallet;
|
||||
|
||||
// This will happen at the chrome extension.
|
||||
const signedTxn = await harmony.wallet.signTransaction(txn); |
||||
|
||||
// Now you can use `Transaction.observed()` to listen events
|
||||
|
||||
// Frontend received back the signedTxn and do the followings to Send transaction.
|
||||
signedTxn |
||||
.observed() |
||||
.on('transactionHash', (txnHash) => { |
||||
console.log(''); |
||||
console.log('--- hash ---'); |
||||
console.log(''); |
||||
console.log(txnHash); |
||||
console.log(''); |
||||
}) |
||||
.on('receipt', (receipt) => { |
||||
console.log(''); |
||||
console.log('--- receipt ---'); |
||||
console.log(''); |
||||
console.log(receipt); |
||||
console.log(''); |
||||
}) |
||||
.on('cxReceipt', (receipt) => { |
||||
console.log(''); |
||||
console.log('--- cxReceipt ---'); |
||||
console.log(''); |
||||
console.log(receipt); |
||||
console.log(''); |
||||
}) |
||||
.on('error', (error) => { |
||||
console.log(''); |
||||
console.log('--- error ---'); |
||||
console.log(''); |
||||
console.log(error); |
||||
console.log(''); |
||||
}); |
||||
|
||||
// send the txn, get [Transaction, transactionHash] as result
|
||||
|
||||
const [sentTxn, txnHash] = await signedTxn.sendTransaction(); |
||||
|
||||
// to confirm the result if it is already there
|
||||
|
||||
const confiremdTxn = await sentTxn.confirm(txnHash); |
||||
|
||||
// if the transactino is cross-shard transaction
|
||||
if (!confiremdTxn.isCrossShard()) { |
||||
if (confiremdTxn.isConfirmed()) { |
||||
console.log('--- Result ---'); |
||||
console.log(''); |
||||
console.log('Normal transaction'); |
||||
console.log(`${txnHash} is confirmed`); |
||||
console.log(''); |
||||
console.log('please see detail in explorer:'); |
||||
console.log(''); |
||||
console.log('https://explorer.harmony.one/#/tx/' + txnHash); |
||||
console.log(''); |
||||
process.exit(); |
||||
} |
||||
} |
||||
if (confiremdTxn.isConfirmed() && confiremdTxn.isCxConfirmed()) { |
||||
console.log('--- Result ---'); |
||||
console.log(''); |
||||
console.log('Cross-Shard transaction'); |
||||
console.log(`${txnHash} is confirmed`); |
||||
console.log(''); |
||||
console.log('please see detail in explorer:'); |
||||
console.log(''); |
||||
console.log('https://explorer.harmony.one/#/tx/' + txnHash); |
||||
console.log(''); |
||||
process.exit(); |
||||
} |
||||
} |
||||
|
||||
// sending from one18n8e7472pg5fqvcfcr5hg0npquha24wsxmjheg to one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
|
||||
(async () => await transfer('one1pf75h0t4am90z8uv3y0dgunfqp4lj8wr3t5rsp'))(); |
@ -1,151 +0,0 @@ |
||||
// import or require Harmony class
|
||||
const { Harmony } = require('@harmony-js/core'); |
||||
|
||||
// import or require settings
|
||||
const { ChainID, ChainType } = require('@harmony-js/utils'); |
||||
|
||||
// const URL_TESTNET = `https://api.s0.pga.hmny.io`;
|
||||
const URL_MAINNET = `https://api.s0.t.hmny.io`; |
||||
// const LOCAL_TESTNET = `http://localhost:9500`;
|
||||
const DEVNET = 'https://api.s0.pga.hmny.io'; |
||||
// 1. initialize the Harmony instance
|
||||
|
||||
const harmony = new Harmony( |
||||
// rpc url
|
||||
DEVNET, |
||||
{ |
||||
// chainType set to Harmony
|
||||
chainType: ChainType.Harmony, |
||||
// chainType set to HmyLocal
|
||||
chainId: ChainID.HmyPangaea, |
||||
}, |
||||
); |
||||
|
||||
// 2. get wallet ready
|
||||
// one18n8e7472pg5fqvcfcr5hg0npquha24wsxmjheg;
|
||||
const phrase = 'genius cable radar memory high catch blossom correct middle wish gentle fiscal'; |
||||
|
||||
// one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
|
||||
// surge welcome lion goose gate consider taste injury health march debris kick
|
||||
|
||||
// add privateKey to wallet
|
||||
// const sender = harmony.wallet.addByMnemonic(phrase);
|
||||
|
||||
// add privateKey to wallet
|
||||
const private = '63e35b761e9df0d50ddcdaa8e33c235b60c991bfed22925a12768b0c08ef822f'; |
||||
// one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy
|
||||
const sender = harmony.wallet.addByPrivateKey(private); |
||||
|
||||
// const sender = harmony.wallet.addByPrivateKey(
|
||||
// 'fd416cb87dcf8ed187e85545d7734a192fc8e976f5b540e9e21e896ec2bc25c3',
|
||||
// );
|
||||
|
||||
// 3. get sharding info
|
||||
async function setSharding() { |
||||
// Harmony is a sharded blockchain, each endpoint have sharding structure,
|
||||
// However sharding structure is different between mainnet, testnet and local testnet
|
||||
// We need to get sharding info before doing cross-shard transaction
|
||||
const res = await harmony.blockchain.getShardingStructure(); |
||||
harmony.shardingStructures(res.result); |
||||
} |
||||
|
||||
// 4. get transaction payload ready
|
||||
|
||||
async function transfer(receiver) { |
||||
// run set sharding first, if you want to make a cross-shard transaction
|
||||
await setSharding(); |
||||
|
||||
//1e18
|
||||
const txn = harmony.transactions.newTx({ |
||||
// token send to
|
||||
to: receiver, |
||||
// amount to send
|
||||
value: '100000000000000000', |
||||
// gas limit, you can use string
|
||||
gasLimit: '210000', |
||||
// send token from shardID
|
||||
shardID: 0, |
||||
// send token to toShardID
|
||||
toShardID: 0, |
||||
// gas Price, you can use Unit class, and use Gwei, then remember to use toWei(), which will be transformed to BN
|
||||
gasPrice: new harmony.utils.Unit('100').asGwei().toWei(), |
||||
}); |
||||
|
||||
// sign the transaction use wallet;
|
||||
|
||||
// This will happen at the chrome extension.
|
||||
const signedTxn = await harmony.wallet.signTransaction(txn); |
||||
|
||||
// Now you can use `Transaction.observed()` to listen events
|
||||
|
||||
// Frontend received back the signedTxn and do the followings to Send transaction.
|
||||
signedTxn |
||||
.observed() |
||||
.on('transactionHash', (txnHash) => { |
||||
console.log(''); |
||||
console.log('--- hash ---'); |
||||
console.log(''); |
||||
console.log(txnHash); |
||||
console.log(''); |
||||
}) |
||||
.on('receipt', (receipt) => { |
||||
console.log(''); |
||||
console.log('--- receipt ---'); |
||||
console.log(''); |
||||
console.log(receipt); |
||||
console.log(''); |
||||
}) |
||||
.on('cxReceipt', (receipt) => { |
||||
console.log(''); |
||||
console.log('--- cxReceipt ---'); |
||||
console.log(''); |
||||
console.log(receipt); |
||||
console.log(''); |
||||
}) |
||||
.on('error', (error) => { |
||||
console.log(''); |
||||
console.log('--- error ---'); |
||||
console.log(''); |
||||
console.log(error); |
||||
console.log(''); |
||||
}); |
||||
|
||||
// send the txn, get [Transaction, transactionHash] as result
|
||||
|
||||
const [sentTxn, txnHash] = await signedTxn.sendTransaction(); |
||||
|
||||
// to confirm the result if it is already there
|
||||
|
||||
const confiremdTxn = await sentTxn.confirm(txnHash); |
||||
|
||||
// if the transactino is cross-shard transaction
|
||||
// if (!confiremdTxn.isCrossShard()) {
|
||||
if (confiremdTxn.isConfirmed()) { |
||||
console.log('--- Result ---'); |
||||
console.log(''); |
||||
console.log('Normal transaction'); |
||||
console.log(`${txnHash} is confirmed`); |
||||
console.log(''); |
||||
console.log('please see detail in explorer:'); |
||||
console.log(''); |
||||
console.log('https://explorer.harmony.one/#/tx/' + txnHash); |
||||
console.log(''); |
||||
process.exit(); |
||||
} |
||||
// }
|
||||
if (confiremdTxn.isConfirmed() && confiremdTxn.isCxConfirmed()) { |
||||
console.log('--- Result ---'); |
||||
console.log(''); |
||||
console.log('Cross-Shard transaction'); |
||||
console.log(`${txnHash} is confirmed`); |
||||
console.log(''); |
||||
console.log('please see detail in explorer:'); |
||||
console.log(''); |
||||
console.log('https://explorer.harmony.one/#/tx/' + txnHash); |
||||
console.log(''); |
||||
process.exit(); |
||||
} |
||||
} |
||||
|
||||
// sending from one18n8e7472pg5fqvcfcr5hg0npquha24wsxmjheg to one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
|
||||
(async () => await transfer('one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy'))(); |
@ -1,137 +0,0 @@ |
||||
// import or require Harmony class
|
||||
const { Harmony } = require('@harmony-js/core'); |
||||
|
||||
// import or require settings
|
||||
const { ChainID, ChainType } = require('@harmony-js/utils'); |
||||
|
||||
//const URL_TESTNET = `https://api.s0.b.hmny.io`;
|
||||
const URL_TESTNET = `localhost:9500`; |
||||
const URL_MAINNET = `https://api.s0.t.hmny.io`; |
||||
|
||||
// 1. initialize the Harmony instance
|
||||
|
||||
const harmony = new Harmony( |
||||
// rpc url
|
||||
URL_TESTNET, |
||||
{ |
||||
// chainType set to Harmony
|
||||
chainType: ChainType.Harmony, |
||||
// chainType set to HmyLocal
|
||||
chainId: ChainID.HmyTestnet, |
||||
}, |
||||
); |
||||
|
||||
// 2. get wallet ready
|
||||
// one18n8e7472pg5fqvcfcr5hg0npquha24wsxmjheg
|
||||
//const phrase = 'genius cable radar memory high catch blossom correct middle wish gentle fiscal';
|
||||
|
||||
// one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
|
||||
// surge welcome lion goose gate consider taste injury health march debris kick
|
||||
|
||||
// add privateKey to wallet
|
||||
//const sender = harmony.wallet.addByMnemonic(phrase);
|
||||
// add privateKey to wallet
|
||||
const private = 'fd416cb87dcf8ed187e85545d7734a192fc8e976f5b540e9e21e896ec2bc25c3'; |
||||
const sender = harmony.wallet.addByPrivateKey(private); |
||||
|
||||
// 3. get sharding info
|
||||
async function setSharding() { |
||||
// Harmony is a sharded blockchain, each endpoint have sharding structure,
|
||||
// However sharding structure is different between mainnet, testnet and local testnet
|
||||
// We need to get sharding info before doing cross-shard transaction
|
||||
const res = await harmony.blockchain.getShardingStructure(); |
||||
harmony.shardingStructures(res.result); |
||||
} |
||||
|
||||
// 4. get transaction payload ready
|
||||
|
||||
async function transfer(receiver) { |
||||
// run set sharding first, if you want to make a cross-shard transaction
|
||||
await setSharding(); |
||||
|
||||
//1e18
|
||||
const txn = harmony.transactions.newTx({ |
||||
// token send to
|
||||
to: receiver, |
||||
// amount to send
|
||||
value: '100000000000000000', |
||||
// gas limit, you can use string
|
||||
gasLimit: '210000', |
||||
// send token from shardID
|
||||
shardID: 0, |
||||
// send token to toShardID
|
||||
toShardID: 0, |
||||
// gas Price, you can use Unit class, and use Gwei, then remember to use toWei(), which will be transformed to BN
|
||||
gasPrice: new harmony.utils.Unit('100').asGwei().toWei(), |
||||
}); |
||||
|
||||
// sign the transaction use wallet;
|
||||
|
||||
// This will happen at the chrome extension.
|
||||
const signedTxn = await harmony.wallet.signTransaction(txn); |
||||
|
||||
// Now you can use `Transaction.observed()` to listen events
|
||||
|
||||
// Frontend received back the signedTxn and do the followings to Send transaction.
|
||||
signedTxn |
||||
.observed() |
||||
.on('transactionHash', (txnHash) => { |
||||
console.log(''); |
||||
console.log('--- hash ---'); |
||||
console.log(''); |
||||
console.log(txnHash); |
||||
console.log(''); |
||||
}) |
||||
.on('receipt', (receipt) => { |
||||
console.log(''); |
||||
console.log('--- receipt ---'); |
||||
console.log(''); |
||||
console.log(receipt); |
||||
console.log(''); |
||||
}) |
||||
.on('cxReceipt', (receipt) => { |
||||
console.log(''); |
||||
console.log('--- cxReceipt ---'); |
||||
console.log(''); |
||||
console.log(receipt); |
||||
console.log(''); |
||||
}) |
||||
.on('error', (error) => { |
||||
console.log(''); |
||||
console.log('--- error ---'); |
||||
console.log(''); |
||||
console.log(error); |
||||
console.log(''); |
||||
}); |
||||
|
||||
// send the txn, get [Transaction, transactionHash] as result
|
||||
|
||||
const [sentTxn, txnHash] = await signedTxn.sendTransaction(); |
||||
|
||||
// to confirm the result if it is already there
|
||||
|
||||
const confiremdTxn = await sentTxn.confirm(txnHash); |
||||
|
||||
// if the transactino is cross-shard transaction
|
||||
if (!confiremdTxn.isCrossShard()) { |
||||
if (confiremdTxn.isConfirmed()) { |
||||
console.log('--- Result ---'); |
||||
console.log(''); |
||||
console.log('Normal transaction'); |
||||
console.log(`${txnHash} is confirmed`); |
||||
console.log(''); |
||||
process.exit(); |
||||
} |
||||
} |
||||
if (confiremdTxn.isConfirmed() && confiremdTxn.isCxConfirmed()) { |
||||
console.log('--- Result ---'); |
||||
console.log(''); |
||||
console.log('Cross-Shard transaction'); |
||||
console.log(`${txnHash} is confirmed`); |
||||
console.log(''); |
||||
process.exit(); |
||||
} |
||||
} |
||||
|
||||
// sending from one18n8e7472pg5fqvcfcr5hg0npquha24wsxmjheg to one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
|
||||
transfer('one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65'); |
Loading…
Reference in new issue