-
Notifications
You must be signed in to change notification settings - Fork 8
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
Well defined default addresses #29
Comments
Notably, the keys all these tools generate all seem to come from the recovery phrase However, we can't easily use 12-word phrases in Cardano because some tools are hard-coded to assume those are old Byron addresses. Therefore, I propose we use this 24-word recovery phrase instead
For this mnemonic, I got the following address & keys
I double-checked these are the same as generated by both Yoroi & Eternl I generated these using the following script with CML import wasm from '@dcspark/cardano-multiplatform-lib-nodejs';
import bip39 from 'bip39';
const baseWords = 'test '.repeat(23) + 'sauce';
const rootKey = wasm.Bip32PrivateKey.from_bip39_entropy(
Buffer.from(
bip39.mnemonicToEntropy(baseWords),
'hex'
),
Buffer.from('')
);
for (let i = 0; i < 20; i++) {
const accountKey = rootKey.derive(1852 + 0x80000000).derive(1815 + 0x80000000).derive(i + 0x80000000);
const paymentKey = accountKey.derive(0).derive(0);
const stakingKey = accountKey.derive(2).derive(0);
const baseAddress = wasm.BaseAddress.new(
wasm.NetworkInfo.preprod().network_id(),
wasm.Credential.new_pub_key(paymentKey.to_public().to_raw_key().hash()),
wasm.Credential.new_pub_key(stakingKey.to_public().to_raw_key().hash())
);
console.log(`Account #${i}: ${baseAddress.to_address().to_bech32()}`);
console.log(`Payment key: ${paymentKey.to_raw_key().to_bech32()}`);
console.log(`Staking key: ${stakingKey.to_raw_key().to_bech32()}`);
console.log();
}
t baseAddress = wasm.BaseAddress.new(
wasm.NetworkInfo.mainnet().network_id(),
wasm.Credential.new_pub_key(paymentKey.to_public().to_raw_key().hash()),
wasm.Credential.new_pub_key(stakingKey.to_public().to_raw_key().hash())
);
console.log(`Account #${i}: ${baseAddress.to_address().to_bech32()}`);
console.log(`Payment key: ${paymentKey.to_raw_key().to_bech32()}`);
console.log(`Staking key: ${stakingKey.to_raw_key().to_bech32()}`);
console.log();
} |
Thanks @SebastienGllmt for trying out DevKit. It's really a good idea to support a set of default addresses out of the box. I verified the above mnemonic with Java code and was able to generate the same keys. One simple approach for now could be for DevKit to automatically top up these addresses with a single transaction during the first time node startup. So, with a 1-second block time, there would probably be at most a 2-second delay in startup. Later, we can explore adding these addresses directly to the genesis file of the node. What should be the default amount for these addresses? 10,000 ADA? Note: Just adding my code here in case anyone is interested in deriving the same in Java.
|
+1, great idea. |
Yeah I think 10K is fine. I guess the most expensive thing somebody might want to do during startup is spin up multiple pools, but they're only 500 ADA each so 10K should be enough. It could be higher though (ex: 100k) |
I guess the tricky part about Cardano is that it can't be that just the addresses and balances are well-defined, but you also need to know the tx id that created these initial addresses so that you can reference them in an input However, I don't think we can easily enforce a tx id that will forever be constant (since any change to the genesis block(s) modifies this), so we'll just have to tell people that there are known UTXOs somewhere and they will have to query to know the tx id to spend them as inputs. (still an improvement over now where there are no known addresses at all) |
I have added default addresses to the Shelley genesis file (under the 'initialFunds' property), and it's working perfectly. Probably, we can display the address, secret keys, and UTxOs with balances for all default addresses during the first start. May be it's too much info. Next, I need to add these address to the show-default-account command output. |
If you use popular tools to spin up local EVM networks like hardhat/anvil, it will print out a bunch of known key pairs that are part of the node by default.
The reason this is really helpful is that is allows people to write tools that default to using these addresses when running on localhost knowing that it will work without any user configuration changes if the user is using hardhat/anvil
It would be useful if yaci also did this. Concretely, in Paima we want users to be able to spin up local nodes with yaci and have the Paima configuration (which requires private keys for account abstraction and other similar things) to just default to these accounts knowing they will exist
Example of hardhat ↓
The text was updated successfully, but these errors were encountered: