Skip to content

Commit

Permalink
Merge pull request #3555 from dfinity/add-secret-key
Browse files Browse the repository at this point in the history
add: info about using keys with Node.js
  • Loading branch information
jessiemongeon1 authored Sep 30, 2024
2 parents f19ac9a + 53594c2 commit 8e573b5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -462,4 +462,4 @@ export const backend_canister = createActor(canisterId);
- [`agent-js` documentation](https://agent-js.icp.xyz/agent/modules.html).
- [`agent-js` npm package](https://www.npmjs.com/package/@dfinity/agent).
- [`agent-js` npm package](https://www.npmjs.com/package/@dfinity/agent).
14 changes: 11 additions & 3 deletions docs/developer-docs/developer-tools/off-chain/agents/nodejs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,16 @@ import { MarkdownChipRow } from "/src/components/Chip/MarkdownChipRow";

## Identity management

Before you set up an actor, you will need to have an identity. You can set up an identity that will resolve a seed phrase to a principal by using the following code:
Before you set up an actor, you will need to have an identity.

### Using keys through `agent-js`

You can configure an authentication identity for Node.js through `agent-js`'s using the ECDSA or Ed25519 private keys. [Learn more in the agent-js docs](https://internetcomputer.org/docs/current/developer-docs/developer-tools/off-chain/agents/javascript-agent).


### Seed phrase

Alternatively, you can set up an identity that will resolve a seed phrase to a principal by using the following code:

```js
// identity.js
Expand All @@ -35,7 +44,6 @@ The seed phrase in this example is derived from the word `test` repeated 12 time
Remember to store any seed phrase you use in production in a secure place. Use environment variables, and never commit a real seed phrase in plain text to your codebase.
:::


## Asset uploading

A community library, `@dfinity/assets`, is available to upload assets to your project's asset canister. You'll need to get the canister ID, pass your agent, and then upload your files. Below is an example code snippet showcasing this workflow:
Expand Down Expand Up @@ -359,4 +367,4 @@ main();
- [ic-websocket-js](https://www.npmjs.com/package/ic-websocket-js)
- [End to end testing](https://internetcomputer.org/docs/current/tutorials/developer-journey/level-2/2.5-unit-testing#end-to-end-e2e-testing)
- [End to end testing](https://internetcomputer.org/docs/current/tutorials/developer-journey/level-2/2.5-unit-testing#end-to-end-e2e-testing)

0 comments on commit 8e573b5

Please sign in to comment.