{"id":601,"date":"2025-10-03T10:06:58","date_gmt":"2025-10-03T10:06:58","guid":{"rendered":"https:\/\/nownodes.io\/blog\/?p=601"},"modified":"2025-10-03T10:06:58","modified_gmt":"2025-10-03T10:06:58","slug":"how-to-make-a-bitcoin-transaction-with-python","status":"publish","type":"post","link":"https:\/\/nownodes.io\/blog\/how-to-make-a-bitcoin-transaction-with-python\/","title":{"rendered":"How to make a Bitcoin transaction with Python"},"content":{"rendered":"\n<p>In the last article, we learned about\u00a0<a href=\"https:\/\/nownodes.io\/blog\/bitcoin-hierarchical-deterministic-wallet-in-python\" target=\"_blank\" rel=\"noreferrer noopener\">creating Bitcoin HD wallets<\/a>. Today, we will talk about how to make a Bitcoin transaction using Python.<\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"prerequisite\"><strong>Prerequisite<\/strong><\/h2>\n\n\n<p>We will be using&nbsp;<a href=\"https:\/\/pypi.org\/project\/bit\/\" target=\"_blank\" rel=\"noreferrer noopener\">bit<\/a>&nbsp;python library, one of the fastest and easiest libraries to develop Bitcoin related applications. To install&nbsp;<a href=\"https:\/\/pypi.org\/project\/bit\/\" target=\"_blank\" rel=\"noreferrer noopener\">bit<\/a>&nbsp;use the following command.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install bit<\/code><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id=\"creating-a-bitcoin-wallet-testnet\"><strong>Creating a Bitcoin wallet (Testnet)<\/strong><\/h2>\n\n\n<p>For this tutorial, we will create a Bitcoin testnet wallet. Because we will be creating transactions and sending bitcoins, so we don\u2019t want you to lose your real bitcoins.<\/p>\n\n\n\n<p>Bitcoin Testnet is a network that simulates the original Bitcoin network but does not have any monetary value. Testnet has test bitcoins. Therefore, do not send you real bitcoins to testnet address, you will lose them.<\/p>\n\n\n\n<p>So, let\u2019s create a simple testnet wallet. For this, create a simple python file transaction.py and copy and paste the code below.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from bit import PrivateKeyTestnet\n\nmy_key = PrivateKeyTestnet()\n\nprint(my_key.version)\n\nprint(my_key.to_wif())\n\nprint(my_key.address)<\/code><\/pre>\n\n\n\n<p>This code will create a simple wallet and print wif (<a href=\"https:\/\/en.bitcoin.it\/wiki\/Wallet_import_format\" target=\"_blank\" rel=\"noreferrer noopener\">Wallet Import Format<\/a>). Using this wif we can get our wallet again.<\/p>\n\n\n\n<p>Otherwise my_key = PrivateKeyTestnet() will generate a new wallet every time.<\/p>\n\n\n\n<p>Therefore, replace my_key = PrivateKeyTestnet() with my_key = PrivateKeyTestnet(\u2018wif\u2019) once you get wif . This way, every time we re-run the above code, we will be using the same wallet.<\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"get-test-bitcoins\"><strong>Get Test Bitcoins<\/strong><\/h2>\n\n\n<p>Now, we need to get some test bitcoins, so we can send it to another wallet.<\/p>\n\n\n\n<p>To get testnet bitcoins, use&nbsp;<a href=\"https:\/\/testnet-faucet.mempool.co\/\" target=\"_blank\" rel=\"noreferrer noopener\">this link<\/a>. Enter the address generated by the above wallet. You can check your testnet transaction&nbsp;<a href=\"https:\/\/blockstream.info\/testnet\/\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>.<\/p>\n\n\n\n<p>Once the transaction is confirmed, you can also check your balance using<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>print(my_key.balance_as('usd'))<\/code><\/pre>\n\n\n\n<p><strong>Note:<\/strong>&nbsp;Testnet bitcoins do not have any monetary value.<\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"creating-transaction\"><strong>Creating Transaction<\/strong><\/h2>\n\n\n<p>Now we are ready to create a transaction. But wait, we need a receiver address, otherwise, where will we send the transaction. You can create another wallet using the method mentioned above. However, for brevity, we will use the following testnet address.<\/p>\n\n\n\n<p><strong>Note:<\/strong>&nbsp;The address below is a Bitcoin testnet address, do not send real bitcoin on this address.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mkH41dfD4S8DEoSfcVSvEfpyZ9siogWWtr<\/code><\/pre>\n\n\n\n<p>Now, we have everything, so we are ready to create a Bitcoin transaction.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tx_hash = my_key.send(&#91;('mkH41dfD4S8DEoSfcVSvEfpyZ9siogWWtr', 1, 'usd')])\n\nprint(tx_hash)<\/code><\/pre>\n\n\n\n<p>Yes, using bit we can create, sign, and broadcast transactions using just one command. In addition,&nbsp;send()&nbsp;method takes an array as a parameter. This means you can create and send multiple transactions in one go.<\/p>\n\n\n\n<p>The code above will print a transaction hash, which we can check on the&nbsp;<a href=\"https:\/\/blockstream.info\/testnet\/\" target=\"_blank\" rel=\"noreferrer noopener\">Bitcoin testnet block explorer<\/a>.<\/p>\n\n\n\n<p>Once the transaction is confirmed you can recheck the balance of your wallet using.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>print(my_key.get_balance())<\/code><\/pre>\n\n\n\n<p>For further reading, check out the\u00a0<a href=\"https:\/\/nownodes.gitbook.io\/btc-bitcoin\/\" target=\"_blank\" rel=\"noreferrer noopener\">bit documentation<\/a>.<\/p>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link has-palette-color-7-color has-vivid-purple-background-color has-text-color has-background has-link-color wp-element-button\" href=\"https:\/\/nownodes.io\/pricing\" target=\"_blank\" rel=\"noreferrer noopener\">Get access to Bitcoin<\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In the last article, we learned about\u00a0creating Bitcoin HD wallets. Today, we will talk about how to make a Bitcoin transaction using Python. Prerequisite We will be using&nbsp;bit&nbsp;python library, one of the fastest and easiest libraries to develop Bitcoin related applications. To install&nbsp;bit&nbsp;use the following command. Creating a Bitcoin wallet (Testnet) For this tutorial, we [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":608,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_eb_attr":"","_lmt_disableupdate":"","_lmt_disable":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[95,7,1],"tags":[96,198,196,197,199,76,39],"class_list":["post-601","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bitcoin","category-node-guides","category-uncategorized","tag-bitcoin","tag-bitcoin-python","tag-bitcoin-testnet","tag-btc-python","tag-python","tag-testnet","tag-tutorial"],"blocksy_meta":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to make a Bitcoin transaction with Python<\/title>\n<meta name=\"description\" content=\"In the last article, we learned about creating Bitcoin HD wallets. Today, we will talk about how to make a Bitcoin transaction using Python.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/nownodes.io\/blog\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to make a Bitcoin transaction with Python\" \/>\n<meta property=\"og:description\" content=\"In the last article, we learned about creating Bitcoin HD wallets. Today, we will talk about how to make a Bitcoin transaction using Python.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/nownodes.io\/blog\/\" \/>\n<meta property=\"og:site_name\" content=\"NOWNodes Blog\" \/>\n<meta property=\"article:published_time\" content=\"2025-10-03T10:06:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/nownodes.io\/blog\/wp-content\/uploads\/2024\/05\/NN_TON-1-min-scaled.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"2560\" \/>\n\t<meta property=\"og:image:height\" content=\"1440\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"NOWNodes Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@nownodes\" \/>\n<meta name=\"twitter:site\" content=\"@nownodes\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"NOWNodes Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/nownodes.io\/blog#article\",\"isPartOf\":{\"@id\":\"https:\/\/nownodes.io\/blog\/how-to-make-a-bitcoin-transaction-with-python\/\"},\"author\":{\"name\":\"NOWNodes Team\",\"@id\":\"https:\/\/nownodes.io\/blog\/#\/schema\/person\/c041891469390738b68a2aafe063f93c\"},\"headline\":\"How to make a Bitcoin transaction with Python\",\"datePublished\":\"2025-10-03T10:06:58+00:00\",\"dateModified\":\"2025-10-03T10:06:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/nownodes.io\/blog\/how-to-make-a-bitcoin-transaction-with-python\/\"},\"wordCount\":444,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/nownodes.io\/blog\/#organization\"},\"keywords\":[\"BItcoin\",\"Bitcoin Python\",\"bitcoin testnet\",\"BTC Python\",\"Python\",\"Testnet\",\"Tutorial\"],\"articleSection\":[\"Bitcoin\",\"Node Guides\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/nownodes.io\/blog#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/nownodes.io\/blog\/how-to-make-a-bitcoin-transaction-with-python\/\",\"url\":\"https:\/\/nownodes.io\/blog\",\"name\":\"How to make a Bitcoin transaction with Python\",\"isPartOf\":{\"@id\":\"https:\/\/nownodes.io\/blog\/#website\"},\"datePublished\":\"2025-10-03T10:06:58+00:00\",\"dateModified\":\"2025-10-03T10:06:58+00:00\",\"description\":\"In the last article, we learned about creating Bitcoin HD wallets. Today, we will talk about how to make a Bitcoin transaction using Python.\",\"breadcrumb\":{\"@id\":\"https:\/\/nownodes.io\/blog#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/nownodes.io\/blog\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/nownodes.io\/blog#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\/\/nownodes.io\/blog\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Node Guides\",\"item\":\"https:\/\/nownodes.io\/blog\/category\/node-guides\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Bitcoin\",\"item\":\"https:\/\/nownodes.io\/blog\/category\/node-guides\/bitcoin\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"How to make a Bitcoin transaction with Python\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/nownodes.io\/blog\/#website\",\"url\":\"https:\/\/nownodes.io\/blog\/\",\"name\":\"NOWNodes Blog\",\"description\":\"Your first-to-go source of development guides, web3 analytics and most recent news about NOWNodes\",\"publisher\":{\"@id\":\"https:\/\/nownodes.io\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/nownodes.io\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/nownodes.io\/blog\/#organization\",\"name\":\"NOWNodes Blog\",\"url\":\"https:\/\/nownodes.io\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/nownodes.io\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/nownodes.io\/blog\/wp-content\/uploads\/2024\/02\/cropped-New-Logo-NN.png\",\"contentUrl\":\"https:\/\/nownodes.io\/blog\/wp-content\/uploads\/2024\/02\/cropped-New-Logo-NN.png\",\"width\":1164,\"height\":1164,\"caption\":\"NOWNodes Blog\"},\"image\":{\"@id\":\"https:\/\/nownodes.io\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/twitter.com\/nownodes\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/nownodes.io\/blog\/#\/schema\/person\/c041891469390738b68a2aafe063f93c\",\"name\":\"NOWNodes Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/nownodes.io\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/084e45aa2f2bfa61b9ce9f41af97a74f38e87c065b0d49f23a1bb84727320c2e?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/084e45aa2f2bfa61b9ce9f41af97a74f38e87c065b0d49f23a1bb84727320c2e?s=96&d=mm&r=g\",\"caption\":\"NOWNodes Team\"},\"sameAs\":[\"http:\/\/65.108.139.113\"],\"url\":\"https:\/\/nownodes.io\/blog\/author\/nownodes\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to make a Bitcoin transaction with Python","description":"In the last article, we learned about creating Bitcoin HD wallets. Today, we will talk about how to make a Bitcoin transaction using Python.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/nownodes.io\/blog\/","og_locale":"en_US","og_type":"article","og_title":"How to make a Bitcoin transaction with Python","og_description":"In the last article, we learned about creating Bitcoin HD wallets. Today, we will talk about how to make a Bitcoin transaction using Python.","og_url":"https:\/\/nownodes.io\/blog\/","og_site_name":"NOWNodes Blog","article_published_time":"2025-10-03T10:06:58+00:00","og_image":[{"width":2560,"height":1440,"url":"https:\/\/nownodes.io\/blog\/wp-content\/uploads\/2024\/05\/NN_TON-1-min-scaled.jpg","type":"image\/jpeg"}],"author":"NOWNodes Team","twitter_card":"summary_large_image","twitter_creator":"@nownodes","twitter_site":"@nownodes","twitter_misc":{"Written by":"NOWNodes Team","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/nownodes.io\/blog#article","isPartOf":{"@id":"https:\/\/nownodes.io\/blog\/how-to-make-a-bitcoin-transaction-with-python\/"},"author":{"name":"NOWNodes Team","@id":"https:\/\/nownodes.io\/blog\/#\/schema\/person\/c041891469390738b68a2aafe063f93c"},"headline":"How to make a Bitcoin transaction with Python","datePublished":"2025-10-03T10:06:58+00:00","dateModified":"2025-10-03T10:06:58+00:00","mainEntityOfPage":{"@id":"https:\/\/nownodes.io\/blog\/how-to-make-a-bitcoin-transaction-with-python\/"},"wordCount":444,"commentCount":0,"publisher":{"@id":"https:\/\/nownodes.io\/blog\/#organization"},"keywords":["BItcoin","Bitcoin Python","bitcoin testnet","BTC Python","Python","Testnet","Tutorial"],"articleSection":["Bitcoin","Node Guides"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/nownodes.io\/blog#respond"]}]},{"@type":"WebPage","@id":"https:\/\/nownodes.io\/blog\/how-to-make-a-bitcoin-transaction-with-python\/","url":"https:\/\/nownodes.io\/blog","name":"How to make a Bitcoin transaction with Python","isPartOf":{"@id":"https:\/\/nownodes.io\/blog\/#website"},"datePublished":"2025-10-03T10:06:58+00:00","dateModified":"2025-10-03T10:06:58+00:00","description":"In the last article, we learned about creating Bitcoin HD wallets. Today, we will talk about how to make a Bitcoin transaction using Python.","breadcrumb":{"@id":"https:\/\/nownodes.io\/blog#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/nownodes.io\/blog"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/nownodes.io\/blog#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/nownodes.io\/blog"},{"@type":"ListItem","position":2,"name":"Node Guides","item":"https:\/\/nownodes.io\/blog\/category\/node-guides"},{"@type":"ListItem","position":3,"name":"Bitcoin","item":"https:\/\/nownodes.io\/blog\/category\/node-guides\/bitcoin"},{"@type":"ListItem","position":4,"name":"How to make a Bitcoin transaction with Python"}]},{"@type":"WebSite","@id":"https:\/\/nownodes.io\/blog\/#website","url":"https:\/\/nownodes.io\/blog\/","name":"NOWNodes Blog","description":"Your first-to-go source of development guides, web3 analytics and most recent news about NOWNodes","publisher":{"@id":"https:\/\/nownodes.io\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/nownodes.io\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/nownodes.io\/blog\/#organization","name":"NOWNodes Blog","url":"https:\/\/nownodes.io\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/nownodes.io\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/nownodes.io\/blog\/wp-content\/uploads\/2024\/02\/cropped-New-Logo-NN.png","contentUrl":"https:\/\/nownodes.io\/blog\/wp-content\/uploads\/2024\/02\/cropped-New-Logo-NN.png","width":1164,"height":1164,"caption":"NOWNodes Blog"},"image":{"@id":"https:\/\/nownodes.io\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/twitter.com\/nownodes"]},{"@type":"Person","@id":"https:\/\/nownodes.io\/blog\/#\/schema\/person\/c041891469390738b68a2aafe063f93c","name":"NOWNodes Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/nownodes.io\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/084e45aa2f2bfa61b9ce9f41af97a74f38e87c065b0d49f23a1bb84727320c2e?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/084e45aa2f2bfa61b9ce9f41af97a74f38e87c065b0d49f23a1bb84727320c2e?s=96&d=mm&r=g","caption":"NOWNodes Team"},"sameAs":["http:\/\/65.108.139.113"],"url":"https:\/\/nownodes.io\/blog\/author\/nownodes"}]}},"modified_by":"\u0410nastasia","_links":{"self":[{"href":"https:\/\/nownodes.io\/blog\/wp-json\/wp\/v2\/posts\/601","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nownodes.io\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nownodes.io\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nownodes.io\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nownodes.io\/blog\/wp-json\/wp\/v2\/comments?post=601"}],"version-history":[{"count":4,"href":"https:\/\/nownodes.io\/blog\/wp-json\/wp\/v2\/posts\/601\/revisions"}],"predecessor-version":[{"id":1795,"href":"https:\/\/nownodes.io\/blog\/wp-json\/wp\/v2\/posts\/601\/revisions\/1795"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nownodes.io\/blog\/wp-json\/wp\/v2\/media\/608"}],"wp:attachment":[{"href":"https:\/\/nownodes.io\/blog\/wp-json\/wp\/v2\/media?parent=601"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nownodes.io\/blog\/wp-json\/wp\/v2\/categories?post=601"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nownodes.io\/blog\/wp-json\/wp\/v2\/tags?post=601"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}