Is there a sandbox in bitcoin for testing? Is there a sandbox in Bitcoin for testing, so that I can create sample bitcoins without mining and do transactions for testing purposes?
Testnet is really heavy (hundreds of gigabytes), there is a lighter alternative to that now: signet. There is also a local-only network called regtest, which I put in its own section. Finally, I'll explain txindex, which is a useful option to have your own mini block explorer.
Signet
To use it, first start bitcoind with the option:
bitcoind -signet

It will need to sync, but it will be a lot faster than testnet since the chain started recently and as of writing only has about 27000 blocks:
% bitcoin-cli -signet getblockchaininfo
{
  &quot;chain&quot;: &quot;signet&quot;,
  &quot;blocks&quot;: 26029

You can use bitcoin-cli -signet getnewaddress to get a new address, which you can paste into the faucet: https://signet.bc-2.jp/ (if it complains that you have no wallet, see next section). Note how signet addresses also start with tb (which is called the &quot;human readable prefix&quot;, hrp), just like testnet addresses.
% bitcoin-cli -signet listunspent
[
  {
    &quot;txid&quot;: &quot;9484eff65e5c33f601a8d6446859ffbc6ba59ffd53dca564d66a7c09e040c26a&quot;,
    &quot;address&quot;: &quot;tb1q7x3nnyskqmgrj9hp95fgfg75fz50x4khay3s0t&quot;,
    &quot;amount&quot;: 10.00000000,
    &quot;confirmations&quot;: 3,

If you don't see anything right away, wait a bit. Once the transaction arrives, you'll see the confirmation count rising at a regular interval. Signet has much more regular blocks than testnet.
Regtest
The regtest is not really a network, since it isn't meant to be used publicly. The chain starts with the genesis, and proof-of-work is effectively disabled, so you can just mine your own blocks. This is useful if you need to test reorgs and stuff like that, which you won't be able to do with signet.
% bitcoind -regtest

Let it run in the a separate terminal window.
Now you should have an empty chain:
% bitcoin-cli -regtest getblockchaininfo
{
  &quot;chain&quot;: &quot;regtest&quot;,
  &quot;blocks&quot;: 0,

Now, lets see if you have a wallet:
% bitcoin-cli -regtest getwalletinfo          
error code: -18
error message:
No wallet is loaded.

If you get an error like this, create a wallet:
% bitcoin-cli -regtest createwallet testwallet
{
  &quot;name&quot;: &quot;testwallet&quot;,
  &quot;warning&quot;: &quot;&quot;
}

Now, you can create a new address:
% bitcoin-cli -regtest getnewaddress          
bcrt1q0qx0d7prvrd64s3e3trq39fet7jwdecstw5tzu

Note how the HRP mentioned above is now &quot;bcrt&quot;, &quot;bitcoin regtest&quot;.
Mining some coins
That's right, CPU mining is alive and well ;) In fact, regtest only has blocks when you generate some, yourself. That's nice for testing, you have time to figure out.
You can mine directly to the wallet (so-called coinbase outputs, you may have heard of a company named after these). Here I am using the shell to insert an address generated using the command from above (should work in PowerShell on Windows too):
% bitcoin-cli -regtest generatetoaddress 10 $(bitcoin-cli -regtest getnewaddress)
[
  &quot;2e25176b5122a3d16eca11355b2807ebf99e8ef3cf01e32634417baf47cb9a4b&quot;,
  &quot;3e8136a62d513925a075700e92789d70da67d5b3dd986e936d65b12a3ba53c72&quot;,
  &quot;55ca10e3932a9087259a3826148aa660e09b69b63fe84d6a81bc4e57de052060&quot;,
  &quot;4864e894662693ae7e32cb0d2a8bc3ad94c4f5e67e109873555bc5f7b5c166bc&quot;,
  &quot;0de8a4bfb5fa5a38fba39dcf9fe360e3382e6fa56c226553c30736525bea659e&quot;,
  &quot;69e3a04724793b90de126358a99f297b821cac83b9be12f3d569effd73729199&quot;,
  &quot;3eb2a83540ce04ef75f5258359ee1695fa0b2e6cbc04a078f85e3182cd500004&quot;,
  &quot;35e39307638bca2db359ee8fa6930fbbf20e5d465882c50e05c05e2510ca2e28&quot;,
  &quot;12f2b855729929aa091a7cffccb66886a6c406c7855f8851c25ab162b17455f1&quot;,
  &quot;2414f3ddfa767aa1916f296066d35ae58c828b49e84542c57509e7161201b746&quot;
]

We mined some bitcoin, but you have to remember that there is &quot;coin maturity&quot;, which means that coins can not be used immediately after mining, not even on regtest.
So after mining these 10 blocks, you'll see that the wallet still reports no unspent outputs:
% bitcoin-cli -regtest listunspent
[
]

To mature the coins, mine a hundred blocks more (I'll omit the output, it's just the command above with 100 instead of 10), and you'll see the coins mined in the first command:
% bitcoin-cli -regtest listunspent
  {
    &quot;txid&quot;: &quot;6fe92df06b95a20db44f989471483802a9aebc56e93057dca9fe0546445d35ff&quot;,
    &quot;vout&quot;: 0,
    &quot;address&quot;: &quot;bcrt1qlu9a5687f3m4ct3r5ndlwy8juppgghysy2s67f&quot;,
    &quot;label&quot;: &quot;&quot;,
    &quot;scriptPubKey&quot;: &quot;0014ff0bda68fe4c775c2e23a4dbf710f2e042845c90&quot;,
    &quot;amount&quot;: 50.00000000,
    &quot;confirmations&quot;: 110,
    &quot;spendable&quot;: true,
    &quot;solvable&quot;: true,
    &quot;desc&quot;: &quot;wpkh([a45ff478/0'/0'/2']02ebc0275e56ecca4a80d6a6ff7d7ab884c972cff9db9a91b9bb3681741624d41a)#rgeusc6u&quot;,
   

There will be a ten tx's like this, because the ten blocks that we initially mined have all matured. They have confirmation counts from 101 to 110.
Processing bitcoin output with jq
Note how you can use standard JSON tools to extract information from the bitcoin-cli output.
For example, we can verify the number of unspent wallet outputs. In the example from the previous section, we mined 110 blocks, that each have one coinbase output for the Core wallet. But only the first 10 have matured:
% bitcoin-cli -regtest listunspent | jq length
10

Starting over, nuke the chain
You'll possibly want to reset your testing environment before and/or after running a test. With regtest, you can remove the whole blockchain. So shut down the bitcoind process that we started above. You can simply wipe the regtest directory, but be very careful that you don't wipe the wrong one (actually, you shouldn't even have real (mainnet) coins in the filesystem that you run your tests from).
% rm -rf ~/.bitcoin/regtest/

This isn't a true factory reset, since if you have any configuration in ~/.bitcoin/bitcoin.conf, it would still be loaded. So if something is still working unexpectedly, check your config.
Deleting a signet blockchain makes less sense, since you'd just download the exact same chain after relaunching (unless something is horribly broken). So to ensure a clean signet testing environment, maybe just wipe everything except blocks, e.g. chainstate, wallets and indexes.
Txindex, your own block explorer
Bitcoin Core has a neat feature that lets you look up information on an arbitrary transaction. But you enable must it first. To do that, write txindex=1 in ~/.bitcoin/bitcoin.conf, possibly in a regtest or signet section, though I just put it at the top-level since my mainnet coins are elsewhere, and it is useful for all testing.
Now, with txindex enabled, you can retrieve information on, lets say, the first transaction of block 1 (right after genesis):
bitcoin-cli -signet decoderawtransaction $(
  bitcoin-cli -signet getrawtransaction $(
    bitcoin-cli -signet getblock $(
      bitcoin-cli -signet getblockhash 1
    ) | jq -r '.tx[0]'
  )
)

You get, for example, the output script these coins were locked with:
  ...
  &quot;vout&quot;: [
    {
      &quot;value&quot;: 50.00000000,
      &quot;n&quot;: 0,
      &quot;scriptPubKey&quot;: {
        &quot;asm&quot;: &quot;0 9243f727dd5343293eb83174324019ec16c2630f&quot;,

The &quot;getrawtransaction&quot; step requires txindex.
This is similar to information that you'll see in a block explorer. In this example, I used signet (which has a public block explorer), but for regtest you obviously won't have a block explorer available, so the txindex could come in handy.