1

I have written a Sol program, but during initialization, I need to fill it with some default addresses.

Question 1: Can I use the Solana burn address: 1nc1nerator11111111111111111111111111111111 from the Solana docs ?

Question 2: Why is this a burn_address.toBase() having only 43 characters, but a randomly generated address.toBase() from web3.Keypair.generate() https://solana-labs.github.io/solana-web3.js/classes/Keypair.html has 44 characters ?

e.g. DyVj5YpgZT51NKJWJkjXbn3UHxKRdS9G1zScSK7NZQEk has 44 characters

Question 3: If I have chosen a default address, e.g. the Solana's burn address, how can I make an address from a string like fromBase58("1nc1nerator11111111111111111111111111111111") ? Using fromSeed(seed: Uint8Array) ?

After making a new account with an array of Pubkey, they have default base58 values of 11111111111111111111111111111111...

4

1 回答 1

3

Seems to be a few questions here!

Question 1: Can I use the Solana burn address: 1nc1nerator11111111111111111111111111111111 from the Solana docs ?

The incinerator address is quite specific to draining SOL to remove it totally from circulation. You can feel free to use it however you wish, but it probably won't behave exactly as you want unless you're working with SOL.

Question 2: Why is this a burn_address.toBase() having only 43 characters, but a randomly generated address.toBase() from web3.Keypair.generate() https://solana-labs.github.io/solana-web3.js/classes/Keypair.html has 44 characters ?

You can think of addresses as 32-byte integers expressed in base58. Since base58 does not divide evenly into 32 bytes, like base16 or base64, we can get different numbers of characters to express it. There's a nice breakdown of this over at https://learnmeabitcoin.com/technical/base58

Question 3: If I have chosen a default address, e.g. the Solana's burn address, how can I make an address from a string like fromBase58("1nc1nerator11111111111111111111111111111111") ? Using fromSeed(seed: Uint8Array) ?

If you're converting from a base58 string, you can just do new PublicKey("1nc1nerator11111111111111111111111111111111"), and the constructor will decode from base58 for you automatically. See the code at https://github.com/solana-labs/solana/blob/6909a79b6fd50f63e2968d4760f864b377e4c802/web3.js/src/publickey.ts#L50

于 2021-08-27T23:08:43.077 回答