<p>A Bitcoin address consists of a 1-byte version, a 20-byte payload (normally the RIPEMD-160 hash of a public key or script), and a 4-byte checksum, all encoded alphanumerically in base58.  This is called Base58Check.  You can see the specific details <a href="https://en.bitcoin.it/wiki/Base58Check_encoding#Creating_a_Base58Check_string" rel="nofollow noreferrer">here</a>, and there are many ready-made implementations in various languages.  In your case, the version byte should be either 111 or 196 (decimal) which are used for testnet pubkeyhash or scripthash addresses respectively.</p>

<p>The reason for your error is probably that you have not computed the checksum correctly.  It is based on a double sha256 of the payload and is explained in the link above.</p>

<p>Note that if you use arbitrary data for the payload (and then include a proper version byte and checksum), you'll get an address which is "valid" and that people can send coins to, but those coins will then be unspendable (since it is not feasible to find a private key for which the hash of the public key equals your chosen data).  So this will effectively destroy any coins sent to that address.</p>

<p>A different technique is a so-called "vanity address", where you use brute force to generate lots of private keys until you find one for which the first few bytes of the address match some desired data.  (The traditional application is to try to make the base58 encoding contain your name or some other meaningful word.)  The classic tool for this is <a href="https://github.com/samr7/vanitygen" rel="nofollow noreferrer">vanitygen</a>.</p>

<p>This lets you embed some data into an address that can actually be used for spending.  However, you won't be able to get anywhere near 20 bytes, since getting n bits of data requires generating an average of 2^n private keys.</p>

CC BY-SA 4.0
2019-09-14T20:58:34.667Z
2019-09-14T20:58:34.667Z
Nate Eldredge
<p>In the very early days of bitcoin, miners injected data into the address where the coins were going, not knowing that bitcoin would be worth $10,000 in 2019. However, I can get bitcoin for free on the testnet network (it has no value). I would like to embed data into the address, but, when I use the base58 encoder, it says "the data is invalid". I want to be able to embed a small message into a testnet blockchain, and this is one way to do it.</p>

CC BY-SA 4.0
2019-09-14T14:13:26.937Z
You appear to be asking about Vanity Addresses such as "1VanityeNpkB3BwFXCDynrejjQYpyDTz7". However your last sentence could also mean the contentious practice of using OP_RETURN as per https://en.bitcoin.it/wiki/OP_RETURN. Could you please clear up which you mean?
Alistair Mann
CC BY-SA 4.0
2019-09-14T15:02:22.480Z
I mean embed the data inside the address, so that the address contains 20 bytes of text or other data.
Number File
CC BY-SA 4.0
2019-09-14T20:50:20.493Z
What base58 encoder are you using, and exactly what input are you giving it?
Nate Eldredge
<blockchain-data-storage>
How can I embed data into a bitcoin testnet address?
Number File
# How can I embed data into a bitcoin testnet address?

(Asked by: username_0 on 2019-09-14)

In the very early days of bitcoin, miners injected data into the address where the coins were going, not knowing that bitcoin would be worth $10,000 in 2019. However, I can get bitcoin for free on the testnet network (it has no value). I would like to embed data into the address, but, when I use the base58 encoder, it says "the data is invalid". I want to be able to embed a small message into a testnet blockchain, and this is one way to do it.

**Tags:** blockchain-data-storage

> **Comments:**
> **username_1**: You appear to be asking about Vanity Addresses such as "1VanityeNpkB3BwFXCDynrejjQYpyDTz7". However your last sentence could also mean the contentious practice of using OP_RETURN as per https://en.bitcoin.it/wiki/OP_RETURN. Could you please clear up which you mean?  
> **username_0**: I mean embed the data inside the address, so that the address contains 20 bytes of text or other data.  
> **username_2**: What base58 encoder are you using, and exactly what input are you giving it?  

---

## 1 answers

### Answer by username_2 on 2019-09-14. Score: 2

A Bitcoin address consists of a 1-byte version, a 20-byte payload (normally the RIPEMD-160 hash of a public key or script), and a 4-byte checksum, all encoded alphanumerically in base58. This is called Base58Check. You can see the specific details [here](https://en.bitcoin.it/wiki/Base58Check_encoding#Creating_a_Base58Check_string), and there are many ready-made implementations in various languages. In your case, the version byte should be either 111 or 196 (decimal) which are used for testnet pubkeyhash or scripthash addresses respectively.

The reason for your error is probably that you have not computed the checksum correctly. It is based on a double sha256 of the payload and is explained in the link above.

Note that if you use arbitrary data for the payload (and then include a proper version byte and checksum), you'll get an address which is "valid" and that people can send coins to, but those coins will then be unspendable (since it is not feasible to find a private key for which the hash of the public key equals your chosen data). So this will effectively destroy any coins sent to that address.

A different technique is a so-called "vanity address", where you use brute force to generate lots of private keys until you find one for which the first few bytes of the address match some desired data. (The traditional application is to try to make the base58 encoding contain your name or some other meaningful word.) The classic tool for this is [vanitygen](https://github.com/samr7/vanitygen).

This lets you embed some data into an address that can actually be used for spending. However, you won't be able to get anywhere near 20 bytes, since getting n bits of data requires generating an average of 2^n private keys.


---

