Skip to content

Conversation

uniyalabhishek
Copy link
Contributor

@uniyalabhishek uniyalabhishek commented Oct 6, 2025

Closes oasisprotocol/oasis-sdk#2298

This PR:

  • Creates a new use case guide for key generation using appd REST
    • This guide goes through how to sign message on EVM chain. Base in this case
    • Generate key for Base via appd key REST API (secp…)
    • Send ETH(test) to ROFL key
    • (Deploy Contract via ROFL key)
    • Send ETH(test) back to user via RPC

The example repo can be found here: https://github.com/uniyalabhishek/demo-rofl-keygen

Copy link

netlify bot commented Oct 6, 2025

Deploy Preview for oasisprotocol-docs ready!

Name Link
🔨 Latest commit f881b47
🔍 Latest deploy log https://app.netlify.com/projects/oasisprotocol-docs/deploys/68e3a1dcfdbd4d0008d2d87d
😎 Deploy Preview https://deploy-preview-1478--oasisprotocol-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@uniyalabhishek uniyalabhishek force-pushed the uniyalabhishek/docs/rofl-keygen-use-case branch 2 times, most recently from 44e18a5 to cef9dea Compare October 6, 2025 10:49
Copy link
Member

@matevz matevz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass

@@ -0,0 +1,576 @@
---
description: Generate an EVM key inside ROFL via appd and use it to sign and send transactions on Base.
tags: [ROFL, appd, keys, EVM]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think KMS became a standard term now for managing the keys.

Suggested change
tags: [ROFL, appd, keys, EVM]
tags: [ROFL, appd, KMS, EVM]

```shell
oasis rofl init rofl-keygen
cd rofl-keygen
````
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
````
```

Comment on lines +66 to +72
src/
appd.ts # talks to appd over /run/rofl-appd.sock
evm.ts # ethers helpers (provider, wallet, tx)
keys.ts # tiny helpers (checksum)
server.ts # HTTP API to drive the demo
contracts/
Counter.sol # optional sample contract
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's us the standard tree command-like project structure style.

Suggested change
src/
appd.ts # talks to appd over /run/rofl-appd.sock
evm.ts # ethers helpers (provider, wallet, tx)
keys.ts # tiny helpers (checksum)
server.ts # HTTP API to drive the demo
contracts/
Counter.sol # optional sample contract
src/
├── appd.ts # talks to appd over /run/rofl-appd.sock
├── evm.ts # ethers helpers (provider, wallet, tx)
├── keys.ts # tiny helpers (checksum)
└── server.ts # HTTP API to drive the demo
contracts/
└── Counter.sol # optional sample contract

Comment on lines +55 to +58
npm init -y
npm i express ethers zod dotenv
npm i -D typescript tsx @types/node @types/express hardhat
npx tsc --init --rootDir src --outDir dist --module NodeNext --target ES2022
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just use hardhat init and select typescript. Then install any extra deps. See how we did it for Sapphire: https://github.com/oasisprotocol/sapphire-paratime/blob/main/docs/quickstart.mdx#init-a-new-hardhat-project

@@ -0,0 +1,576 @@
---
description: Generate an EVM key inside ROFL via appd and use it to sign and send transactions on Base.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For those who don't know what EVM stands for.

Suggested change
description: Generate an EVM key inside ROFL via appd and use it to sign and send transactions on Base.
description: Generate an Ethereum-compatible key inside ROFL via appd and use it to sign and send transactions on Base.

});
}

export async function getEvmPrivateKey(keyId: string): Promise<string> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow best security practices and use SecretKey instead of PrivateKey.

Suggested change
export async function getEvmPrivateKey(keyId: string): Promise<string> {
export async function getEvmSecretKey(keyId: string): Promise<string> {

Comment on lines +220 to +222
export function privateKeyToWallet(pkHex: string): Wallet {
return new Wallet(pkHex);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export function privateKeyToWallet(pkHex: string): Wallet {
return new Wallet(pkHex);
}
export function secretKeyToWallet(skHex: string): Wallet {
return new Wallet(skHex);
}


</details>

### `src/server.ts` — minimal HTTP API
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think running another HTTP API is not a good idea. There is a REST server already running and accessible at /run/rofl/appd.sock for this purpose.

Users that want to have EVM-signing capability would need to integrate your HTTP API anyway, so why not connecting to appd directly? Instead of server.ts I'd write a simple test that uses appd, get the key, sign an EVM transaction and submit it to Base.

1. **Get App ID**

```shell
curl -s https://YOUR-PROXY/app-id | jq
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YOUR_PROXY is the machine name defined in compose.yaml. Also, https won't work out of the box since the domain is not managed by CA and self-signed certs are not allowed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ROFL Guides / Examples
2 participants