Skip to content

Commit ce281d3

Browse files
chore: update examples to use ECDSA accounts (#3458)
Signed-off-by: Mario Dimitrov <[email protected]>
1 parent bde9652 commit ce281d3

File tree

70 files changed

+127
-121
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+127
-121
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ jobs:
217217

218218
- name: Set Operator Account
219219
run: |
220-
echo "OPERATOR_KEY=${{ steps.solo.outputs.ed25519PrivateKey }}" >> $GITHUB_ENV
221-
echo "OPERATOR_ID=${{ steps.solo.outputs.ed25519AccountId }}" >> $GITHUB_ENV
220+
echo "OPERATOR_KEY=${{ steps.solo.outputs.ecdsaPrivateKey }}" >> $GITHUB_ENV
221+
echo "OPERATOR_ID=${{ steps.solo.outputs.ecdsaAccountId }}" >> $GITHUB_ENV
222222
echo "HEDERA_NETWORK=local-node" >> $GITHUB_ENV
223223
224224
- name: Install dependencies

examples/.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Local Node
2-
OPERATOR_KEY=0xa608e2130a0a3cb34f86e757303c862bee353d9ab77ba4387ec084f881d420d4
3-
OPERATOR_ID=0.0.1022
2+
OPERATOR_KEY=0x105d050185ccb907fba04dd92d8de9e32c18305e097ab41dadda21489a211524
3+
OPERATOR_ID=0.0.1012
44
HEDERA_NETWORK=local-node
55

66
NODE_COMMAND=node

examples/account-alias.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ async function main() {
5858

5959
console.log('"Creating" a new account');
6060

61-
const privateKey = PrivateKey.generateED25519();
61+
const privateKey = PrivateKey.generateECDSA();
6262
const publicKey = privateKey.publicKey;
6363

6464
// Assuming that the target shard and realm are known.

examples/account-allowance.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ async function main() {
4040

4141
console.log("Generating accounts for example...");
4242

43-
const aliceKey = PrivateKey.generateED25519();
44-
const bobKey = PrivateKey.generateED25519();
45-
const charlieKey = PrivateKey.generateED25519();
43+
const aliceKey = PrivateKey.generateECDSA();
44+
const bobKey = PrivateKey.generateECDSA();
45+
const charlieKey = PrivateKey.generateECDSA();
4646

4747
try {
4848
let transaction = await new AccountCreateTransaction()

examples/account-create-with-hts.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,13 @@ async function main() {
4747
const supplyKey = PrivateKey.generateECDSA();
4848
const freezeKey = PrivateKey.generateECDSA();
4949
const wipeKey = PrivateKey.generateECDSA();
50-
5150
if (process.env.OPERATOR_ID == null || process.env.OPERATOR_KEY == null) {
5251
throw new Error(
5352
"Environment variables OPERATOR_ID, and OPERATOR_KEY are required.",
5453
);
5554
}
5655
const operatorId = AccountId.fromString(process.env.OPERATOR_ID);
57-
const operatorKey = PrivateKey.fromStringDer(process.env.OPERATOR_KEY);
56+
const operatorKey = PrivateKey.fromStringECDSA(process.env.OPERATOR_KEY);
5857

5958
const nodes = {
6059
"127.0.0.1:50211": new AccountId(3),

examples/batch-tx.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ async function main() {
3232
}
3333

3434
const operatorAccId = AccountId.fromString(process.env.OPERATOR_ID);
35-
const operatorPrivKey = PrivateKey.fromStringED25519(
35+
const operatorPrivKey = PrivateKey.fromStringECDSA(
3636
process.env.OPERATOR_KEY,
3737
);
3838

examples/change-or-remove-token-keys.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,22 @@ async function main() {
3333

3434
// Configure client using environment variables
3535
const operatorId = AccountId.fromString(process.env.OPERATOR_ID);
36-
const operatorKey = PrivateKey.fromStringED25519(process.env.OPERATOR_KEY);
36+
const operatorKey = PrivateKey.fromStringECDSA(process.env.OPERATOR_KEY);
3737

3838
const client = Client.forName(network).setOperator(operatorId, operatorKey);
3939

4040
// Set logger
4141
const infoLogger = new Logger(LogLevel.Info);
4242
client.setLogger(infoLogger);
4343

44-
const adminKey = PrivateKey.generateED25519();
45-
const supplyKey = PrivateKey.generateED25519();
46-
const newSupplyKey = PrivateKey.generateED25519();
47-
const wipeKey = PrivateKey.generateED25519();
48-
const freezeKey = PrivateKey.generateED25519();
49-
const pauseKey = PrivateKey.generateED25519();
50-
const feeScheduleKey = PrivateKey.generateED25519();
51-
const metadataKey = PrivateKey.generateED25519();
44+
const adminKey = PrivateKey.generateECDSA();
45+
const supplyKey = PrivateKey.generateECDSA();
46+
const newSupplyKey = PrivateKey.generateECDSA();
47+
const wipeKey = PrivateKey.generateECDSA();
48+
const freezeKey = PrivateKey.generateECDSA();
49+
const pauseKey = PrivateKey.generateECDSA();
50+
const feeScheduleKey = PrivateKey.generateECDSA();
51+
const metadataKey = PrivateKey.generateECDSA();
5252

5353
// This HIP introduces ability to remove lower-privilege keys (Wipe, KYC, Freeze, Pause, Supply, Fee Schedule, Metadata) from a Token:
5454
// - using an update with the empty KeyList;

examples/consensus-pub-sub.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/contract-nonces.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ async function main() {
3636
try {
3737
const fileCreateTxResponse = await (
3838
await new FileCreateTransaction()
39-
.setKeys([PrivateKey.fromStringDer(process.env.OPERATOR_KEY)])
39+
.setKeys([PrivateKey.fromStringECDSA(process.env.OPERATOR_KEY)])
4040
.setContents(SMART_CONTRACT_BYTECODE)
4141
.setMaxTransactionFee(new Hbar(2))
4242
.freezeWithSigner(wallet)
@@ -48,7 +48,9 @@ async function main() {
4848

4949
const contractCreateTxResponse = await (
5050
await new ContractCreateTransaction()
51-
.setAdminKey(PrivateKey.fromStringDer(process.env.OPERATOR_KEY))
51+
.setAdminKey(
52+
PrivateKey.fromStringECDSA(process.env.OPERATOR_KEY),
53+
)
5254
.setGas(100000)
5355
.setBytecodeFileId(newFileId)
5456
.setContractMemo(

examples/create-account-with-alias-and-receiver-signature.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ dotenv.config();
1515
/*
1616
Reference: [HIP-583 Expand alias support in CryptoCreate & CryptoTransfer Transactions](https://hips.hedera.com/hip/hip-583)
1717
## Example 1:
18-
- Create an ECSDA private key and an ED25519 admin private key
18+
- Create an ECSDA private key and an ECDSA admin private key
1919
- Extract the ECDSA public key
2020
- Extract the Ethereum public address
2121
- Use the `AccountCreateTransaction`
@@ -32,7 +32,7 @@ async function main() {
3232
);
3333
}
3434
const operatorId = AccountId.fromString(process.env.OPERATOR_ID);
35-
const operatorKey = PrivateKey.fromStringDer(process.env.OPERATOR_KEY);
35+
const operatorKey = PrivateKey.fromStringECDSA(process.env.OPERATOR_KEY);
3636

3737
const nodes = {
3838
"127.0.0.1:50211": new AccountId(3),
@@ -47,9 +47,9 @@ async function main() {
4747
/**
4848
* Step 1
4949
*
50-
* Create an ECSDA private key and an ED25519 admin private key
50+
* Create an ECSDA private key and an ECDSA admin private key
5151
*/
52-
const adminKey = PrivateKey.generateED25519();
52+
const adminKey = PrivateKey.generateECDSA();
5353
console.log(`Admin private key: ${adminKey.toStringDer()}`);
5454

5555
const privateKey = PrivateKey.generateECDSA();

0 commit comments

Comments
 (0)