howl.moe

gno: what is test1?

Published on 20/09/2024 by Morgan Bazalgette • 2 minutes
it's not a testnet; not anymore, at least. instead, it's the name of a well-known address and associated mnemonic, often used when testing.
source bonus chronic canvas draft south burst lottery vacant surface solve popular case indicate oppose farm nothing bullet exhibit title speed wink action roast

i have this mnemonic saved in my password manager, given how often i find myself copy-and-pasting it somewhere, whether on a blog post or into my gnokey keychain. it has the following address (with the default account number and sequence): g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5.

if you search for it in the gno repository, you'll see it has a bunch of hits:

$ rg g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5 | wc -l
77

aside from being an address whose mnemonic is known and anyone can use, it has a few "features":

the latter has an important consequence: it is the std.GetOrigCaller() and std.PrevRealm() that is called in all init() functions and variable initializations of examples/ packages.

so, while it is normally a good idea to set an admin like this (it allows people to fork your code and re-deploy, and automatically have their address as an admin):

var admin = std.PrevRealm().Addr()
// or:
var ownable = ownable.New() // p/demo/ownable, uses PrevRealm().Addr()

it is not if you're going to add it to the examples/ directory. (unless you want everyone to be able to admin your realm, of course).

... there's also test2!

which has the address g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj, and has the same amount of premine as test1. as far as i know, its mnemonic is not well known. but it still has a role: it's used as the caller for all the default genesis transactions. (though, differently from test1, it's not hard-coded in any go code).