<p><strong>1. Bitcoin single signature P2SH:</strong></p>
<p><em>RedeemScript Template</em> = “[PubKey] OP_CHECKSIG”</p>
<p>Working Examples:</p>
<p><code>% echo &quot;[020ae29f86f404e4b302cfa17ff15d93149af6a54c80a4172d47e41f55f6a78d73] checksig&quot; | bx script-encode</code></p>
<p><em><strong>21020ae29f86f404e4b302cfa17ff15d93149af6a54c80a4172d47e41f55f6a78d73ac</strong></em> (Script)</p>
<p><code>% echo &quot;[020ae29f86f404e4b302cfa17ff15d93149af6a54c80a4172d47e41f55f6a78d73] checksig&quot; | bx script-encode | bx sha256 | bx ripemd160</code></p>
<p><em><strong>49e266a68641d2caa6696b00696f00f0a5706350</strong></em>   (Hash Answer)</p>
<p><code>% echo &quot;[020ae29f86f404e4b302cfa17ff15d93149af6a54c80a4172d47e41f55f6a78d73] checksig&quot; | bx script-encode | bx sha256 | bx ripemd160 | bx base58check-encode -v 5</code></p>
<p><em><strong>38RgUAR367PFbFFgS57BYcERHkpqHEMBvA</strong></em>  (Address)</p>
<p>or more simply,</p>
<p><code>% echo &quot;[020ae29f86f404e4b302cfa17ff15d93149af6a54c80a4172d47e41f55f6a78d73] checksig&quot; | bx script-to-address -v 5</code></p>
<p><em><strong>38RgUAR367PFbFFgS57BYcERHkpqHEMBvA</strong></em></p>
<p><strong>2. Bitcoin BIP16 multisig:</strong></p>
<p><em>2 of 3 RedeemScript Template</em> = &quot;OP_2 [PubKey1] [PubKey2] [PubKey3] OP_3 OP_CHECKMULTISIG&quot;</p>
<p>Working Examples:</p>
<p><code>% echo &quot;2 [020ae29f86f404e4b302cfa17ff15d93149af6a54c80a4172d47e41f55f6a78d73] [03664d528eb80096671ef9011c533ceb5df133238e3690d88f2960c786398b86b1] [029a449ea4a2155ea10002d704604bb3e8606631d35af20889a74b82b2dab572f6] 3 checkmultisig&quot; | bx script-encode</code></p>
<p><em><strong>5221020ae29f86f404e4b302cfa17ff15d93149af6a54c80a4172d47e41f55f6a78d732103664d528eb80096671ef9011c533ceb5df133238e3690d88f2960c786398b86b121029a449ea4a2155ea10002d704604bb3e8606631d35af20889a74b82b2dab572f653ae</strong></em> (Script)</p>
<p><code>%  echo &quot;2 [020ae29f86f404e4b302cfa17ff15d93149af6a54c80a4172d47e41f55f6a78d73] [03664d528eb80096671ef9011c533ceb5df133238e3690d88f2960c786398b86b1] [029a449ea4a2155ea10002d704604bb3e8606631d35af20889a74b82b2dab572f6] 3 checkmultisig&quot; | bx script-encode | bx bitcoin160</code></p>
<p><em><strong>7e580c3a86432d96dd60784e99f5a94e463414fe</strong></em>   (Hash Answer)</p>
<p><code>% echo &quot;2 [020ae29f86f404e4b302cfa17ff15d93149af6a54c80a4172d47e41f55f6a78d73] [03664d528eb80096671ef9011c533ceb5df133238e3690d88f2960c786398b86b1] [029a449ea4a2155ea10002d704604bb3e8606631d35af20889a74b82b2dab572f6] 3 checkmultisig&quot; | bx script-to-address -v 5</code></p>
<p><em><strong>3DD4YP2T75TQtf84KrHzYVLYgNAeaHWqxq</strong></em> (Address)</p>
<p><strong>3. Bitcoin P2WPKH-nested-in-P2SH:</strong></p>
<p><em>RedeemScript Template</em> = &quot;0 [PubKey]&quot;</p>
<p>Working Examples:</p>
<p><code>% echo &quot;0 [020ae29f86f404e4b302cfa17ff15d93149af6a54c80a4172d47e41f55f6a78d73]&quot; | bx script-encode</code></p>
<p><em><strong>0021020ae29f86f404e4b302cfa17ff15d93149af6a54c80a4172d47e41f55f6a78d73</strong></em> (Script)</p>
<p><code>% echo &quot;0 [020ae29f86f404e4b302cfa17ff15d93149af6a54c80a4172d47e41f55f6a78d73]&quot; | bx script-encode | bx bitcoin160</code></p>
<p><em><strong>7138cbb443e9ed635d3dd02a3e450884e3f9f0c8</strong></em>  (Hash Answer)</p>
<p><code>% echo &quot;0 [020ae29f86f404e4b302cfa17ff15d93149af6a54c80a4172d47e41f55f6a78d73]&quot; | bx script-to-address -v 5</code></p>
<p><em><strong>3C1gKTRSAwSLj8Ft1eYooLkWxwJ5cqDdpb</strong></em>  (Address)</p>

CC BY-SA 4.0
2019-04-13T01:35:42.193Z
2019-04-13T01:56:12.390Z
2020-06-16T11:10:03.350Z
skaht
<p>currently the most use case for P2SH tx are multisig constructions. They usually contain s.th. like this:</p>

<pre><code>OP_2 &lt;Pubkey1&gt; &lt;Pubkey2&gt; &lt;Pubkey3&gt; OP_3 OP_CHECKMULTISIG
</code></pre>

<p>This is a 2-of-3 multisig redeemscript, which is then hashed, and returns on mainnet an address starting with "3". It does not contain the receiver address, it contains the public keys.</p>

<p>Looking a bit in the forum on P2SH and multisig, you find useful info, and of course multisig is not the only use case for P2SH. Smart contracts are also a common usage. I recommend reading the <a href="https://bitcoin.org/en/developer-examples#p2sh-multisig" rel="nofollow noreferrer">developer examples</a> and references for multisig p2sh, and also Andreas' book "Mastering Bitcoin". Here especially chapter 7 on advanced transactions. It is an amazing book that'll definitely get you started. It's freely available <a href="http://chimera.labs.oreilly.com/books/1234000001802/index.html" rel="nofollow noreferrer">online here</a>.</p>

CC BY-SA 4.0
2018-07-31T15:24:14.027Z
Another example is for BIP 49 P2WPKH-nested-in-P2SH redemptions (currently used by Trezor segwit-enabled devices), i.e. ```OP_0 <HASH160(Pubkey)>```
skaht
CC BY-SA 3.0
2018-03-19T06:57:37.643Z
2018-03-19T06:59:16.083Z
2018-03-19T06:59:16.083Z
pebwindkraft
<p>What are the contents of a redeem script hash in a p2sh transaction?</p>

<p>From what i read it's similar to the pubkey script but does it only contain the receiver's address?</p>

<transactions><script>
P2sh redeem script hash
John
# P2sh redeem script hash

(Asked by: username_0 on 2018-03-18)

What are the contents of a redeem script hash in a p2sh transaction?

From what i read it's similar to the pubkey script but does it only contain the receiver's address?

**Tags:** transactions, script


---

## 2 answers

### Answer by username_1 on 2019-04-13. Score: 1

**1. Bitcoin single signature P2SH:**

*RedeemScript Template* = “[PubKey] OP\_CHECKSIG”

Working Examples:

`% echo "[020ae29f86f404e4b302cfa17ff15d93149af6a54c80a4172d47e41f55f6a78d73] checksig" | bx script-encode`

***21020ae29f86f404e4b302cfa17ff15d93149af6a54c80a4172d47e41f55f6a78d73ac*** (Script)

`% echo "[020ae29f86f404e4b302cfa17ff15d93149af6a54c80a4172d47e41f55f6a78d73] checksig" | bx script-encode | bx sha256 | bx ripemd160`

***49e266a68641d2caa6696b00696f00f0a5706350*** (Hash Answer)

`% echo "[020ae29f86f404e4b302cfa17ff15d93149af6a54c80a4172d47e41f55f6a78d73] checksig" | bx script-encode | bx sha256 | bx ripemd160 | bx base58check-encode -v 5`

***38RgUAR367PFbFFgS57BYcERHkpqHEMBvA*** (Address)

or more simply,

`% echo "[020ae29f86f404e4b302cfa17ff15d93149af6a54c80a4172d47e41f55f6a78d73] checksig" | bx script-to-address -v 5`

***38RgUAR367PFbFFgS57BYcERHkpqHEMBvA***

**2. Bitcoin BIP16 multisig:**

*2 of 3 RedeemScript Template* = "OP\_2 [PubKey1] [PubKey2] [PubKey3] OP\_3 OP\_CHECKMULTISIG"

Working Examples:

`% echo "2 [020ae29f86f404e4b302cfa17ff15d93149af6a54c80a4172d47e41f55f6a78d73] [03664d528eb80096671ef9011c533ceb5df133238e3690d88f2960c786398b86b1] [029a449ea4a2155ea10002d704604bb3e8606631d35af20889a74b82b2dab572f6] 3 checkmultisig" | bx script-encode`

***5221020ae29f86f404e4b302cfa17ff15d93149af6a54c80a4172d47e41f55f6a78d732103664d528eb80096671ef9011c533ceb5df133238e3690d88f2960c786398b86b121029a449ea4a2155ea10002d704604bb3e8606631d35af20889a74b82b2dab572f653ae*** (Script)

`% echo "2 [020ae29f86f404e4b302cfa17ff15d93149af6a54c80a4172d47e41f55f6a78d73] [03664d528eb80096671ef9011c533ceb5df133238e3690d88f2960c786398b86b1] [029a449ea4a2155ea10002d704604bb3e8606631d35af20889a74b82b2dab572f6] 3 checkmultisig" | bx script-encode | bx bitcoin160`

***7e580c3a86432d96dd60784e99f5a94e463414fe*** (Hash Answer)

`% echo "2 [020ae29f86f404e4b302cfa17ff15d93149af6a54c80a4172d47e41f55f6a78d73] [03664d528eb80096671ef9011c533ceb5df133238e3690d88f2960c786398b86b1] [029a449ea4a2155ea10002d704604bb3e8606631d35af20889a74b82b2dab572f6] 3 checkmultisig" | bx script-to-address -v 5`

***3DD4YP2T75TQtf84KrHzYVLYgNAeaHWqxq*** (Address)

**3. Bitcoin P2WPKH-nested-in-P2SH:**

*RedeemScript Template* = "0 [PubKey]"

Working Examples:

`% echo "0 [020ae29f86f404e4b302cfa17ff15d93149af6a54c80a4172d47e41f55f6a78d73]" | bx script-encode`

***0021020ae29f86f404e4b302cfa17ff15d93149af6a54c80a4172d47e41f55f6a78d73*** (Script)

`% echo "0 [020ae29f86f404e4b302cfa17ff15d93149af6a54c80a4172d47e41f55f6a78d73]" | bx script-encode | bx bitcoin160`

***7138cbb443e9ed635d3dd02a3e450884e3f9f0c8*** (Hash Answer)

`% echo "0 [020ae29f86f404e4b302cfa17ff15d93149af6a54c80a4172d47e41f55f6a78d73]" | bx script-to-address -v 5`

***3C1gKTRSAwSLj8Ft1eYooLkWxwJ5cqDdpb*** (Address)


---

### Answer by username_2 on 2018-03-19. Score: 0

currently the most use case for P2SH tx are multisig constructions. They usually contain s.th. like this:

```
OP_2 <Pubkey1> <Pubkey2> <Pubkey3> OP_3 OP_CHECKMULTISIG

```

This is a 2-of-3 multisig redeemscript, which is then hashed, and returns on mainnet an address starting with "3". It does not contain the receiver address, it contains the public keys.

Looking a bit in the forum on P2SH and multisig, you find useful info, and of course multisig is not the only use case for P2SH. Smart contracts are also a common usage. I recommend reading the [developer examples](https://bitcoin.org/en/developer-examples#p2sh-multisig) and references for multisig p2sh, and also Andreas' book "Mastering Bitcoin". Here especially chapter 7 on advanced transactions. It is an amazing book that'll definitely get you started. It's freely available [online here](http://chimera.labs.oreilly.com/books/1234000001802/index.html).

> **Comments:**
> **username_1**: Another example is for BIP 49 P2WPKH-nested-in-P2SH redemptions (currently used by Trezor segwit-enabled devices), i.e. ```OP_0 <HASH160(Pubkey)>```  

---

