o1-labs / zkapp-cli

CLI to create a zkApp (zero-knowledge app) for Mina Protocol
https://docs.minaprotocol.com/zkapps/how-to-write-a-zkapp
Apache License 2.0
114 stars 43 forks source link

[Lightnet] Add a CLI command to acquire a keypair instead of using a JS script #560

Closed MartinMinkov closed 7 months ago

MartinMinkov commented 7 months ago

Describe the problem

When deploying using the lightnet option, I often want to specify a feepayer that is already in the ledger. Before running zk config, I run the following script to get a keypair for a valid feepayer:

import { Lightnet, Mina } from 'o1js';

const network = Mina.Network({
  mina: 'http://localhost:8080/graphql',
  archive: 'http://localhost:8282',
  lightnetAccountManager: 'http://localhost:8181',
});
Mina.setActiveInstance(network);

const feePayerPrivateKey = (await Lightnet.acquireKeyPair()).privateKey;
const feePayerAccount = feePayerPrivateKey.toPublicKey();

console.log(
  `Keypair: ${feePayerPrivateKey.toBase58()} ${feePayerAccount.toBase58()}`
);

This is slightly annoying as everytime I want to do this workflow of setting up a new feepayer, I need to create a script, run it, then copy the keypair into a new file.

Describe the proposed solution

Add a command that acquires a new keypair by using something like zk lightnet get-keypair

Alternatives considered

No response

Importance

nice to have

Additional Information

No response

shimkiv commented 7 months ago

Thanks @MartinMinkov. Do you think it will bring value? Because, for example, we have this task https://github.com/o1-labs/zkapp-cli/issues/528 that essentially will simplify a lot the way you interact with lightnet using zkapp-cli. For now you can always query account manager using any other http client and get information you need (start with opening http://localhost:8181 in web-browser and you will see the usage information).

MartinMinkov commented 7 months ago

Completing #528 would be great for DX, I would love to see it incorporated into the CLI asap!

Opening up the web interface for the account manager is an okay workaround for now; I'll just use that instead. The issue I have is that it adds extra steps to setting up the config, but we already have an issue to address this so that's great to know

shimkiv commented 7 months ago

@MartinMinkov in a light of published version with the zk config --lightnet that automates deploy aliases creation and the availability of the web interface for accounts manager, do you think we still need this to be implemented? It is probably redundant now.

MartinMinkov commented 7 months ago

Yep, I agree! I'll close this issue now.