-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Added spending plans for testing on testnet. #3136
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[ | ||
{ | ||
"id": "c758c095-342c-4607-9db5-867d7e90ab9d", | ||
"name": "partner name", | ||
"ethAddresses": ["0x7d102fe71af42790fe31b126c1f49766376ca2b5", "0x4ad27ba9330cb336b0ee38bfb5b86da015500342"], | ||
"ipAddresses": ["127.0.0.1", "128.0.0.1"], | ||
"subscriptionTier": "PRIVILEGED" | ||
}, | ||
{ | ||
"id": "a68488b0-6f7d-44a0-87c1-774ad64615f2", | ||
"name": "some other partner that has given us only eth addresses", | ||
"ethAddresses": ["0x40183ec818c1826114767391989ff2eaebc2b91e", "0x1fd56166627bee3fc51c0918451e3391f463219c"], | ||
"subscriptionTier": "PRIVILEGED" | ||
}, | ||
{ | ||
"id": "af13d6ed-d676-4d33-8b9d-cf05d1ad7134", | ||
"name": "supported project name", | ||
"ethAddresses": ["0x421e224dfe6717d94a03ce23741c2d7c6009f2dc", "0x149294f355f62827748988071de70ab195d0eb23"], | ||
"ipAddresses": ["129.0.0.1", "130.0.0.1"], | ||
"subscriptionTier": "EXTENDED" | ||
}, | ||
{ | ||
"id": "7f665aa3-6b73-41d7-bf9b-92d04cdab96b", | ||
"name": "some other supported project that has given us only ip addresses", | ||
"ipAddresses": ["131.0.0.1", "132.0.0.1"], | ||
"subscriptionTier": "EXTENDED" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/*- | ||
* | ||
* Hedera JSON RPC Relay | ||
* | ||
* Copyright (C) 2022-2024 Hedera Hashgraph, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
const { Client, PrivateKey, TransferTransaction, AccountId, Hbar } = require('@hashgraph/sdk'); | ||
const { exit } = require('process'); | ||
|
||
const operatorAccountId = process.env.OPERATOR_ID_MAIN; | ||
const operatorPrivateKey = process.env.OPERATOR_KEY_MAIN; | ||
|
||
|
||
if (!operatorAccountId || !operatorPrivateKey) { | ||
throw new Error('Operator ID and Private Key must be set.'); | ||
} | ||
|
||
let client; | ||
if(process.env.HEDERA_NETWORK === 'testnet') { | ||
client = Client.forTestnet(); | ||
} else { | ||
client = Client.forPreviewnet(); | ||
} | ||
|
||
client.setOperator(operatorAccountId, operatorPrivateKey); | ||
|
||
const numberOfAccounts = 4; | ||
|
||
// Initial balance for each new account (in tinybars) | ||
const initialBalanceTinybar = Hbar.fromTinybars(1000000000); // Equivalent to 10 HBAR | ||
|
||
async function main() { | ||
|
||
for (let i = 1; i <= numberOfAccounts; i++) { | ||
console.log(`\n=== Creating Alias Account ${i} ===`); | ||
|
||
const privateKey = PrivateKey.generateECDSA(); | ||
const publicKey = privateKey.publicKey; | ||
|
||
console.log(`Generated ECDSA Private Key: ${privateKey.toStringRaw()}`); | ||
console.log(`Generated ECDSA Public Key: ${publicKey.toStringRaw()}`); | ||
|
||
const ethereumAddress = publicKey.toEthereumAddress(); | ||
|
||
console.log(`Ethereum Address: 0x${ethereumAddress.toString()}`); | ||
|
||
const aliasAccountId = AccountId.fromEvmAddress(0, 0, ethereumAddress); | ||
|
||
const transferTx = await new TransferTransaction() | ||
.addHbarTransfer(operatorAccountId, initialBalanceTinybar.negated()) | ||
.addHbarTransfer(aliasAccountId, initialBalanceTinybar) | ||
.execute(client); | ||
|
||
const receipt = await transferTx.getReceipt(client); | ||
console.log(`Transfer Transaction Status: ${receipt.status.toString()}`); | ||
|
||
} | ||
|
||
exit(); | ||
} | ||
|
||
main().catch((error) => { | ||
console.error('Error creating alias accounts:', error); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works fine, but I've seen the
AccountCreateTransaction
API used before, like this:Just a suggestion—no need to change anything!