2

Good day! I am currently running a program where I wish to create an SPL token and utilize it on my frontend. However, when I start up the test validator, I wish to also be able to run a file that will create said SPL token and the associated wallet for my provider. Is there a way to do this? Any help is greatly appreciated!

1 Answer 1

1

The easiest way is to provide some genesis account files for your test validator which will create the mint and associated token account.

Here's how you can get the accounts:

$ solana-test-validator -r
$ spl-token create-token
Creating token A5t3wQXK1G5ymr7Naa45euNEn7cVqqo5E6BdzPWMMMYA under program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA

Address:  A5t3wQXK1G5ymr7Naa45euNEn7cVqqo5E6BdzPWMMMYA
Decimals:  9

Signature: 5jytLruwiqsPu2TbforENMHJvnChmWVYgKo8W6x2NW36sTnvV6bSxLioEH96Z8E7hHjf3wXyfsprYaYp5A7qG2oZ

$ spl-token create-account A5t3wQXK1G5ymr7Naa45euNEn7cVqqo5E6BdzPWMMMYA
Creating account FTTUP1qiH3FpmqQ8eeY7JH5GYEVnFL1UFAKn1pC71UkC

Signature: xGWZUfn7PkLq6bmboJ2p7G5rYEbfnq3zVNVmzux8xeuLHAs8jyzwZVEwsr6HygSuzVosMaMCuuYnYG9UWtH3WEC

$ solana account --output json -o mint.json A5t3wQXK1G5ymr7Naa45euNEn7cVqqo5E6BdzPWMMMYA
$ solana account --output json -o account.json FTTUP1qiH3FpmqQ8eeY7JH5GYEVnFL1UFAKn1pC71UkC

And then use them:

$ solana-test-validator -r \
  --account FTTUP1qiH3FpmqQ8eeY7JH5GYEVnFL1UFAKn1pC71UkC account.json \
  --account A5t3wQXK1G5ymr7Naa45euNEn7cVqqo5E6BdzPWMMMYA mint.json

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.