{"id":15868,"date":"2022-07-20T20:45:00","date_gmt":"2022-07-20T20:45:00","guid":{"rendered":"https:\/\/hederav2stg.wpenginepowered.com\/blog\/how-to-send-and-receive-hbar-using-smart-contracts-part-1-using-the-sdk\/"},"modified":"2025-12-10T05:11:22","modified_gmt":"2025-12-10T05:11:22","slug":"how-to-send-and-receive-hbar-using-smart-contracts-part-1-using-the-sdk","status":"publish","type":"post","link":"https:\/\/hedera.com\/blog\/how-to-send-and-receive-hbar-using-smart-contracts-part-1-using-the-sdk\/","title":{"rendered":"How to Send and Receive HBAR Using Smart Contracts \u2013 Part 1: Using the SDK"},"content":{"rendered":"<div class=\"body-text BodyCopy mb-40 style-1\">\n<p>Smart contracts on Hedera can hold and exchange value in the form of HBAR, Hedera Token Service (HTS) tokens, and even ERC tokens. This is fundamental for building decentralized applications that rely on contracts in areas like DeFi, ESG, NFT marketplaces, DAOs, and more. <\/p>\n<p>In this tutorial, you will learn how to send and receive HBAR to and from Hedera contracts. At a high level, there are two ways to transfer HBAR to and from a contract on Hedera: the SDKs and Solidity.\u00a0<\/p>\n<p>Part 1 focuses on using the Hedera SDKs. Read <a href=\"https:\/\/hedera.com\/blog\/how-to-send-and-receive-hbar-using-smart-contracts-part-2-solidity\" target=\"_blank\">Part 2<\/a> for transferring HBAR to and from contracts using Solidity.<\/p>\n<h4 class=\"color-ultraviolet\"><strong>Try It Yourself<\/strong><\/h4>\n<ul>\n<li>Get a <a href=\"https:\/\/portal.hedera.com\/register\" target=\"_blank\">Hedera testnet account<\/a><\/li>\n<li>Use <a href=\"https:\/\/codesandbox.io\/s\/hedera-example-transfer-hbar2contracts-sdk-2jt9go\" target=\"_blank\">this Codesandbox<\/a> to try the example\n<ul>\n<li>Fork the sandbox<\/li>\n<li>Remember to provide your testnet account credentials in the .env file<\/li>\n<li>Open a new terminal to execute index.js<\/li>\n<\/ul>\n<\/li>\n<li>Get the <a href=\"https:\/\/github.com\/ed-marquez\/hedera-smart-contracts\/tree\/examples\/examples\/transfer-hbar2contracts-sdk\" target=\"_blank\">example code from GitHub<\/a><\/li>\n<\/ul>\n<h4 class=\"color-ultraviolet\"><strong>Transfer HBAR Using the SDKs<\/strong><\/h4>\n<p>Here are a few key points about transferring HBAR to and from contracts using the SDKs:<\/p>\n<ul>\n<li>For most, this is the simplest method as it only involves doing a <strong><a href=\"https:\/\/docs.hedera.com\/hedera\/sdks-and-apis\/sdks\/cryptocurrency\/transfer-cryptocurrency\" target=\"_blank\">TransferTransaction()<\/a><\/strong><\/li>\n<li>Transferring HBAR <u>to<\/u> a contract:\n<ul>\n<li>Does not require having:\n<ul>\n<li><em>payable<\/em> contracts or functions <\/li>\n<li><em>receive() <\/em>or <em>fallback()<\/em> functions<\/li>\n<\/ul>\n<\/li>\n<li>Keep in mind that if your contract has a <em>fallback()<\/em><br \/>\nfunction, this approach does not invoke it (so that code won\u2019t execute)<\/li>\n<\/ul>\n<\/li>\n<li>Transferring HBAR <u>from<\/u> a contract:\n<ul>\n<li>The contract sending the HBAR must have an admin key to sign the <strong><a href=\"https:\/\/docs.hedera.com\/hedera\/sdks-and-apis\/sdks\/cryptocurrency\/transfer-cryptocurrency\" target=\"_blank\">TransferTransaction()<\/a><\/strong><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h4 class=\"color-ultraviolet\"><strong>Example<\/strong><\/h4>\n<p>This example has three entities: the operator, Alice, and the contract. Your testnet credentials should be used for the operator variables, which are used to initialize the Hedera client that submits transactions to the network and gets confirmations. Create Alice\u2019s account with an initial balance of 100 HBAR, and then Alice will transfer 10 HBAR to the smart contract using the <strong><a href=\"https:\/\/docs.hedera.com\/hedera\/sdks-and-apis\/sdks\/cryptocurrency\/transfer-cryptocurrency\" target=\"_blank\">TransferTransaction()<\/a><\/strong><br \/>\nmodule in the SDK.<\/p>\n<p>Below is the Solidity code for the contract. You can get the bytecode from Codesandbox, the GitHub repository, or by compiling the code.<\/p>\n<\/div>\n<div class=\"hedera-code-window\" style=\"background-image:url('https:\/\/hedera.com\/wp-content\/uploads\/2025\/12\/CodeSnippetBackground-scaled.jpg');padding:24px;border-radius:8px;margin:24px 0;\">\n<p>  <!-- Hidden image so WP All Import downloads this background image into Media Library --><br \/>\n  <img decoding=\"async\" src=\"https:\/\/hedera.com\/wp-content\/uploads\/2025\/12\/CodeSnippetBackground-scaled.jpg\" alt=\"code window background\" style=\"display:none;\" \/><\/p>\n<div class=\"code-window-header\">\n<div class=\"code-window-title\"><\/div>\n<div class=\"code-window-body\"><\/div>\n<\/p><\/div>\n<pre><code class=\"language-javascript\">\/\/ SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.7.0 <0.9.0;\n \n contract hbar2Contract{\n\n    function getBalance() public view returns (uint) {\n        return address(this).balance;\n    }\n}\n<\/code><\/pre>\n<\/div>\n<div class=\"body-text BodyCopy mb-40 style-1\">\n<h4 class=\"color-ultraviolet\">1. Create Accounts<\/h4>\n<p>Generate a private key for Alice. Hedera supports <a href=\"https:\/\/docs.hedera.com\/hedera\/sdks-and-apis\/sdks\/keys\/generate-a-new-key-pair#ed25519\" target=\"_blank\">ED25519<\/a><br \/>\nand <a href=\"https:\/\/docs.hedera.com\/hedera\/sdks-and-apis\/sdks\/keys\/generate-a-new-key-pair#ecdsa-secp256k1_-_\" target=\"_blank\">ECDSA<\/a><br \/>\nkeys.<\/p>\n<\/div>\n<div class=\"hedera-code-window\" style=\"background-image:url('https:\/\/hedera.com\/wp-content\/uploads\/2025\/12\/CodeSnippetBackground-scaled.jpg');padding:24px;border-radius:8px;margin:24px 0;\">\n<p>  <!-- Hidden image so WP All Import downloads this background image into Media Library --><br \/>\n  <img decoding=\"async\" src=\"https:\/\/hedera.com\/wp-content\/uploads\/2025\/12\/CodeSnippetBackground-scaled.jpg\" alt=\"code window background\" style=\"display:none;\" \/><\/p>\n<div class=\"code-window-header\">\n<div class=\"code-window-title\"><\/div>\n<div class=\"code-window-body\"><\/div>\n<\/p><\/div>\n<pre><code class=\"language-javascript\">const aliceKey = PrivateKey.generateECDSA();\n<\/code><\/pre>\n<\/div>\n<div class=\"body-text BodyCopy mb-40 style-1\">\n<p>Create Alice\u2019s account with a balance of 100 HBAR. The function <strong><em>accountCreatorFcn<\/em><\/strong><br \/>\nsimplifies the account creation process and is reusable in case you need to create more accounts in the future. This function uses the <strong><a href=\"https:\/\/docs.hedera.com\/hedera\/sdks-and-apis\/sdks\/cryptocurrency\/create-an-account\" target=\"_blank\">AccountCreateTransaction()<\/a><\/strong><br \/>\nmodule. We\u2019ll use this modular approach throughout the article.<\/p>\n<\/div>\n<div class=\"hedera-code-window\" style=\"background-image:url('https:\/\/hedera.com\/wp-content\/uploads\/2025\/12\/CodeSnippetBackground-scaled.jpg');padding:24px;border-radius:8px;margin:24px 0;\">\n<p>  <!-- Hidden image so WP All Import downloads this background image into Media Library --><br \/>\n  <img decoding=\"async\" src=\"https:\/\/hedera.com\/wp-content\/uploads\/2025\/12\/CodeSnippetBackground-scaled.jpg\" alt=\"code window background\" style=\"display:none;\" \/><\/p>\n<div class=\"code-window-header\">\n<div class=\"code-window-title\"><\/div>\n<div class=\"code-window-body\"><\/div>\n<\/p><\/div>\n<pre><code class=\"language-javascript\">\/\/ Create additional accounts needed\nconst initialBalance = 100;\nconst [accStatus, aliceId] = await accountCreatorFcn(aliceKey, initialBalance);\nconsole.log(\n\t`n- Created Alice's account with initial balance of ${initialBalance} hbar: ${accStatus}`\n);\n<\/code><\/pre>\n<\/div>\n<div class=\"hedera-code-window\" style=\"background-image:url('https:\/\/hedera.com\/wp-content\/uploads\/2025\/12\/CodeSnippetBackground-scaled.jpg');padding:24px;border-radius:8px;margin:24px 0;\">\n<p>  <!-- Hidden image so WP All Import downloads this background image into Media Library --><br \/>\n  <img decoding=\"async\" src=\"https:\/\/hedera.com\/wp-content\/uploads\/2025\/12\/CodeSnippetBackground-scaled.jpg\" alt=\"code window background\" style=\"display:none;\" \/><\/p>\n<div class=\"code-window-header\">\n<div class=\"code-window-title\"><\/div>\n<div class=\"code-window-body\"><\/div>\n<\/p><\/div>\n<pre><code class=\"language-javascript\">async function accountCreatorFcn(pvKey, iBal) {\n\tconst response = await new AccountCreateTransaction()\n\t\t.setInitialBalance(new Hbar(iBal))\n\t\t.setKey(pvKey.publicKey)\n\t\t.setAlias(pvKey.publicKey.toEvmAddress())\n\t\t.execute(client);\n\tconst receipt = await response.getReceipt(client);\n\treturn [receipt.status, receipt.accountId];\n}\n<\/code><\/pre>\n<\/div>\n<div class=\"body-text BodyCopy mb-40 style-1\">\n<p><strong><em>Console Output:<\/em><\/strong><\/p>\n<p><em>- Created Alice's account with initial balance of 100 hbar: SUCCESS<\/em><\/p>\n<h4 class=\"color-ultraviolet\"><strong>2. Deploy the Contract on Hedera<\/strong><\/h4>\n<p>The compiled contract bytecode is a binary contained in the variable <strong><em>contractBytecode<\/em><\/strong>. The function <strong><em>contractCreatorFcn<\/em><\/strong> uses the <strong><a href=\"https:\/\/docs.hedera.com\/hedera\/sdks-and-apis\/sdks\/smart-contracts\/create-a-smart-contract#contractcreateflow\" target=\"_blank\">ContractCreateFlow()<\/a><\/strong><br \/>\nmodule and returns the contract ID and corresponding Solidity address for the contract.<\/p>\n<\/div>\n<div class=\"hedera-code-window\" style=\"background-image:url('https:\/\/hedera.com\/wp-content\/uploads\/2025\/12\/CodeSnippetBackground-scaled.jpg');padding:24px;border-radius:8px;margin:24px 0;\">\n<p>  <!-- Hidden image so WP All Import downloads this background image into Media Library --><br \/>\n  <img decoding=\"async\" src=\"https:\/\/hedera.com\/wp-content\/uploads\/2025\/12\/CodeSnippetBackground-scaled.jpg\" alt=\"code window background\" style=\"display:none;\" \/><\/p>\n<div class=\"code-window-header\">\n<div class=\"code-window-title\"><\/div>\n<div class=\"code-window-body\"><\/div>\n<\/p><\/div>\n<pre><code class=\"language-javascript\">\/\/ Import the compiled contract bytecode\nconst contractBytecode = fs.readFileSync(\"transferHbar2Contract_sdk_sol_hbar2Contract.bin\");\n\n\/\/ Deploy the contract on Hedera\nconst [contractId, contractAddress] = await contractCreatorFcn(contractBytecode);\nconsole.log(`n- The smart contract ID is: ${contractId}`);\nconsole.log(`- The smart contract ID in Solidity format is: ${contractAddress}`);\n<\/code><\/pre>\n<\/div>\n<div class=\"body-text BodyCopy mb-40 style-1\">\n<p><strong><a href=\"https:\/\/docs.hedera.com\/hedera\/sdks-and-apis\/sdks\/smart-contracts\/create-a-smart-contract#contractcreateflow\" target=\"_blank\">ContractCreateFlow()<\/a><\/strong><br \/>\nstores the bytecode and deploys the contract on Hedera. This single call handles for you the operations <strong><a href=\"https:\/\/docs.hedera.com\/hedera\/sdks-and-apis\/sdks\/file-storage\/create-a-file\" target=\"_blank\">FileCreateTransaction()<\/a><\/strong>, <strong><a href=\"https:\/\/docs.hedera.com\/hedera\/sdks-and-apis\/sdks\/file-storage\/append-to-a-file\" target=\"_blank\">FileAppendTransaction()<\/a><\/strong>, and <strong><a href=\"https:\/\/docs.hedera.com\/hedera\/sdks-and-apis\/sdks\/smart-contracts\/create-a-smart-contract#contractcreatetransaction\" target=\"_blank\">ContractCreateTransaction()<\/a><\/strong>. <\/p>\n<p>Set a gas value that is enough to execute the transaction; otherwise, you'll get the error CONTRACT_REVERT_EXECUTED.<\/p>\n<\/div>\n<div class=\"hedera-code-window\" style=\"background-image:url('https:\/\/hedera.com\/wp-content\/uploads\/2025\/12\/CodeSnippetBackground-scaled.jpg');padding:24px;border-radius:8px;margin:24px 0;\">\n<p>  <!-- Hidden image so WP All Import downloads this background image into Media Library --><br \/>\n  <img decoding=\"async\" src=\"https:\/\/hedera.com\/wp-content\/uploads\/2025\/12\/CodeSnippetBackground-scaled.jpg\" alt=\"code window background\" style=\"display:none;\" \/><\/p>\n<div class=\"code-window-header\">\n<div class=\"code-window-title\"><\/div>\n<div class=\"code-window-body\"><\/div>\n<\/p><\/div>\n<pre><code class=\"language-javascript\">async function contractCreatorFcn(contractBytecode) {\n\tconst contractDeployTx = await new ContractCreateFlow()\n\t\t.setBytecode(contractBytecode)\n\t\t.setGas(100000)\n\t\t.execute(client);\n\tconst contractDeployRx = await contractDeployTx.getReceipt(client);\n\tconst contractId = contractDeployRx.contractId;\n\tconst contractAddress = contractId.toSolidityAddress();\n\treturn [contractId, contractAddress];\n}\n<\/code><\/pre>\n<\/div>\n<div class=\"body-text BodyCopy mb-40 style-1\">\n<p><strong><em>Console Output:<\/em><\/strong><\/p>\n<p><em>- The smart contract ID is: 0.0.47716894<\/em><\/p>\n<p><em>- The smart contract ID in Solidity format is: 0000000000000000000000000000000002d81a1e<\/em><\/p>\n<h4 class=\"color-ultraviolet\"><strong>3. Transfer HBAR to the Contract<\/strong><\/h4>\n<p>Transfer 10 HBAR to the contract from Alice\u2019s account using the function <strong><em>hbarTransferFcn<\/em><\/strong>.<\/p>\n<\/div>\n<div class=\"hedera-code-window\" style=\"background-image:url('https:\/\/hedera.com\/wp-content\/uploads\/2025\/12\/CodeSnippetBackground-scaled.jpg');padding:24px;border-radius:8px;margin:24px 0;\">\n<p>  <!-- Hidden image so WP All Import downloads this background image into Media Library --><br \/>\n  <img decoding=\"async\" src=\"https:\/\/hedera.com\/wp-content\/uploads\/2025\/12\/CodeSnippetBackground-scaled.jpg\" alt=\"code window background\" style=\"display:none;\" \/><\/p>\n<div class=\"code-window-header\">\n<div class=\"code-window-title\"><\/div>\n<div class=\"code-window-body\"><\/div>\n<\/p><\/div>\n<pre><code class=\"language-javascript\">\/\/ Transfer HBAR to smart contract using TransferTransaction()\nconst hbarAmount = 10;\nconst transferRx = await hbarTransferFcn(aliceId, contractId, hbarAmount);\nconsole.log(`n- Transfer ${hbarAmount} HBAR from Alice to contract: ${transferRx.status}`);\n<\/code><\/pre>\n<\/div>\n<div class=\"body-text BodyCopy mb-40 style-1\">\n<p>Use the <strong><a href=\"https:\/\/docs.hedera.com\/hedera\/sdks-and-apis\/sdks\/cryptocurrency\/transfer-cryptocurrency\" target=\"_blank\">TransferTransaction()<\/a><\/strong><br \/>\nmodule to transfer the HBAR. Remember that the account for which the balance is deducted must sign the transfer transaction (Alice in this case). <\/p>\n<\/div>\n<div class=\"hedera-code-window\" style=\"background-image:url('https:\/\/hedera.com\/wp-content\/uploads\/2025\/12\/CodeSnippetBackground-scaled.jpg');padding:24px;border-radius:8px;margin:24px 0;\">\n<p>  <!-- Hidden image so WP All Import downloads this background image into Media Library --><br \/>\n  <img decoding=\"async\" src=\"https:\/\/hedera.com\/wp-content\/uploads\/2025\/12\/CodeSnippetBackground-scaled.jpg\" alt=\"code window background\" style=\"display:none;\" \/><\/p>\n<div class=\"code-window-header\">\n<div class=\"code-window-title\"><\/div>\n<div class=\"code-window-body\"><\/div>\n<\/p><\/div>\n<pre><code class=\"language-javascript\">async function hbarTransferFcn(sender, receiver, amount) {\n\tconst transferTx = new TransferTransaction()\n\t\t.addHbarTransfer(sender, -amount)\n\t\t.addHbarTransfer(receiver, amount)\n\t\t.freezeWith(client);\n\tconst transferSign = await transferTx.sign(aliceKey);\n\tconst transferSubmit = await transferSign.execute(client);\n\tconst transferRx = await transferSubmit.getReceipt(client);\n\treturn transferRx;\n}\n<\/code><\/pre>\n<\/div>\n<div class=\"body-text BodyCopy mb-40 style-1\">\n<p><strong><em>Console Output:<\/em><\/strong><\/p>\n<p><em>- Transfer 10 HBAR from Alice to contract: SUCCESS<\/em><\/p>\n<h4 class=\"color-ultraviolet\"><strong>4. Check the Balance of the Contract<\/strong><\/h4>\n<p>Finally, use the function <strong><em>contractBalanceCheckerFcn<\/em><br \/>\n<\/strong>to check the HBAR balance of the contract. This function checks the balance in two ways: 1) calling the <strong><em>getBalance<\/em><\/strong> function in the contract via a <strong><a href=\"https:\/\/docs.hedera.com\/hedera\/sdks-and-apis\/sdks\/smart-contracts\/call-a-smart-contract-function-1\" target=\"_blank\">ContractCallQuery()<\/a><\/strong>, and 2) using the <strong><a href=\"https:\/\/docs.hedera.com\/hedera\/sdks-and-apis\/sdks\/smart-contracts\/get-smart-contract-info\" target=\"_blank\">ContractInfoQuery()<\/a><\/strong><br \/>\nmodule of the SDK.<\/p>\n<\/div>\n<div class=\"hedera-code-window\" style=\"background-image:url('https:\/\/hedera.com\/wp-content\/uploads\/2025\/12\/CodeSnippetBackground-scaled.jpg');padding:24px;border-radius:8px;margin:24px 0;\">\n<p>  <!-- Hidden image so WP All Import downloads this background image into Media Library --><br \/>\n  <img decoding=\"async\" src=\"https:\/\/hedera.com\/wp-content\/uploads\/2025\/12\/CodeSnippetBackground-scaled.jpg\" alt=\"code window background\" style=\"display:none;\" \/><\/p>\n<div class=\"code-window-header\">\n<div class=\"code-window-title\"><\/div>\n<div class=\"code-window-body\"><\/div>\n<\/p><\/div>\n<pre><code class=\"language-javascript\">\/\/ Query the contract balance\nconst [fromCallQuery, fromInfoQuery] = await contractBalanceCheckerFcn(contractId);\nconsole.log(`n- Contract balance (from getBalance fcn): ${fromCallQuery} tinybars`);\nconsole.log(`- Contract balance (from ContractInfoQuery): ${fromInfoQuery.balance.toString()}`);\n<\/code><\/pre>\n<\/div>\n<div class=\"hedera-code-window\" style=\"background-image:url('https:\/\/hedera.com\/wp-content\/uploads\/2025\/12\/CodeSnippetBackground-scaled.jpg');padding:24px;border-radius:8px;margin:24px 0;\">\n<p>  <!-- Hidden image so WP All Import downloads this background image into Media Library --><br \/>\n  <img decoding=\"async\" src=\"https:\/\/hedera.com\/wp-content\/uploads\/2025\/12\/CodeSnippetBackground-scaled.jpg\" alt=\"code window background\" style=\"display:none;\" \/><\/p>\n<div class=\"code-window-header\">\n<div class=\"code-window-title\"><\/div>\n<div class=\"code-window-body\"><\/div>\n<\/p><\/div>\n<pre><code class=\"language-javascript\">async function contractBalanceCheckerFcn(contractId) {\n\tconst contractQueryTx = new ContractCallQuery()\n\t\t.setContractId(contractId)\n\t\t.setGas(100000)\n\t\t.setFunction(\"getBalance\");\n\tconst contractQuerySubmit = await contractQueryTx.execute(client);\n\tconst contractQueryResult = contractQuerySubmit.getUint256(0);\n\n\tconst cCheck = await new ContractInfoQuery().setContractId(contractId).execute(client);\n\treturn [contractQueryResult, cCheck];\n}\n<\/code><\/pre>\n<\/div>\n<div class=\"body-text BodyCopy mb-40 style-1\">\n<p><strong><em>Console Output:<\/em><\/strong><\/p>\n<p><em>- Contract balance (from getBalance fcn): 1000000000 tinybars<\/em><\/p>\n<p><em>- Contract balance (from ContractInfoQuery): 10 \u210f<\/em><\/p>\n<h4 class=\"color-ultraviolet\"><strong>Summary<\/strong><\/h4>\n<p>Now you know how to <u>send HBAR <strong>to<\/strong> a contract<\/u> on Hedera using the <strong><a href=\"https:\/\/docs.hedera.com\/hedera\/sdks-and-apis\/sdks\/cryptocurrency\/transfer-cryptocurrency\" target=\"_blank\">TransferTransaction()<\/a><\/strong><br \/>\nmodule of the SDK. <\/p>\n<p>You can also <u>send HBAR <strong>from<\/strong> a contract<\/u> using the SDK. However, the contract sending the HBAR must have an admin key to sign the <strong><a href=\"https:\/\/docs.hedera.com\/hedera\/sdks-and-apis\/sdks\/cryptocurrency\/transfer-cryptocurrency\" target=\"_blank\">TransferTransaction()<\/a><\/strong>. <\/p>\n<p>For contracts without admin keys, be sure to read <a href=\"https:\/\/hedera.com\/blog\/how-to-send-and-receive-hbar-using-smart-contracts-part-2-solidity\">Part 2<\/a>. There you\u2019ll learn how to transfer HBAR to\/from contracts using Solidity.<\/p>\n<\/p>\n<h4 class=\"color-ultraviolet\"><strong>Continue Learning<\/strong><\/h4>\n<ul>\n<li><a href=\"https:\/\/portal.hedera.com\/register\">Open a Testnet Account<\/a><\/li>\n<li><a href=\"https:\/\/docs.hedera.com\/hedera\/tutorials\">Try Examples<\/a><br \/>\nand <a href=\"https:\/\/docs.hedera.com\/hedera\/tutorials\">Tutorials<\/a><\/li>\n<li><a href=\"http:\/\/hedera.com\/discord\">Join the Developer Discord<\/a><\/li>\n<li><a href=\"https:\/\/hedera.com\/learning\">Read the Learning Center<\/a><\/li>\n<\/ul>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Smart contracts on Hedera can hold and exchange value in the form of HBAR, Hedera Token Service (HTS) tokens, and even ERC tokens. This is fundamental for building decentralized applications that rely on contracts in areas like DeFi, ESG, NFT marketplaces, DAOs, and more. In this tutorial, you will learn how to send and receive HBAR to and from Hedera contracts. Part 1 focuses on using the Hedera SDKs.<\/p>\n","protected":false},"author":10,"featured_media":18043,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"content-type":"","footnotes":""},"categories":[1],"tags":[45],"ppma_author":[43],"class_list":["post-15868","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-technical"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Send and Receive HBAR Using Smart Contracts \u2013 Part 1: Using the SDK | Hedera<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/hedera.com\/blog\/how-to-send-and-receive-hbar-using-smart-contracts-part-1-using-the-sdk\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Send and Receive HBAR Using Smart Contracts \u2013 Part 1: Using the SDK | Hedera\" \/>\n<meta property=\"og:description\" content=\"Smart contracts on Hedera can hold and exchange value in the form of HBAR, Hedera Token Service (HTS) tokens, and even ERC tokens. This is fundamental for building decentralized applications that rely on contracts in areas like DeFi, ESG, NFT marketplaces, DAOs, and more. In this tutorial, you will learn how to send and receive HBAR to and from Hedera contracts. Part 1 focuses on using the Hedera SDKs.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/hedera.com\/blog\/how-to-send-and-receive-hbar-using-smart-contracts-part-1-using-the-sdk\/\" \/>\n<meta property=\"og:site_name\" content=\"Hedera\" \/>\n<meta property=\"article:published_time\" content=\"2022-07-20T20:45:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-12-10T05:11:22+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/hedera.com\/wp-content\/uploads\/2025\/12\/0-Cover-image-scaled.png\" \/>\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\/png\" \/>\n<meta name=\"author\" content=\"Hedera Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/hedera.com\/blog\/how-to-send-and-receive-hbar-using-smart-contracts-part-1-using-the-sdk\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/hedera.com\/blog\/how-to-send-and-receive-hbar-using-smart-contracts-part-1-using-the-sdk\/\"},\"author\":{\"name\":\"Hedera Team\",\"@id\":\"https:\/\/hedera.com\/#\/schema\/person\/2dc6146f9f20a44d3de58c834d52e9f4\"},\"headline\":\"How to Send and Receive HBAR Using Smart Contracts \u2013 Part 1: Using the SDK\",\"datePublished\":\"2022-07-20T20:45:00+00:00\",\"dateModified\":\"2025-12-10T05:11:22+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/hedera.com\/blog\/how-to-send-and-receive-hbar-using-smart-contracts-part-1-using-the-sdk\/\"},\"wordCount\":712,\"publisher\":{\"@id\":\"https:\/\/hedera.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/hedera.com\/blog\/how-to-send-and-receive-hbar-using-smart-contracts-part-1-using-the-sdk\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/hedera.com\/wp-content\/uploads\/2025\/12\/0-Cover-image-scaled.png\",\"keywords\":[\"technical\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/hedera.com\/blog\/how-to-send-and-receive-hbar-using-smart-contracts-part-1-using-the-sdk\/\",\"url\":\"https:\/\/hedera.com\/blog\/how-to-send-and-receive-hbar-using-smart-contracts-part-1-using-the-sdk\/\",\"name\":\"How to Send and Receive HBAR Using Smart Contracts \u2013 Part 1: Using the SDK | Hedera\",\"isPartOf\":{\"@id\":\"https:\/\/hedera.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/hedera.com\/blog\/how-to-send-and-receive-hbar-using-smart-contracts-part-1-using-the-sdk\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/hedera.com\/blog\/how-to-send-and-receive-hbar-using-smart-contracts-part-1-using-the-sdk\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/hedera.com\/wp-content\/uploads\/2025\/12\/0-Cover-image-scaled.png\",\"datePublished\":\"2022-07-20T20:45:00+00:00\",\"dateModified\":\"2025-12-10T05:11:22+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/hedera.com\/blog\/how-to-send-and-receive-hbar-using-smart-contracts-part-1-using-the-sdk\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/hedera.com\/blog\/how-to-send-and-receive-hbar-using-smart-contracts-part-1-using-the-sdk\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/hedera.com\/blog\/how-to-send-and-receive-hbar-using-smart-contracts-part-1-using-the-sdk\/#primaryimage\",\"url\":\"https:\/\/hedera.com\/wp-content\/uploads\/2025\/12\/0-Cover-image-scaled.png\",\"contentUrl\":\"https:\/\/hedera.com\/wp-content\/uploads\/2025\/12\/0-Cover-image-scaled.png\",\"width\":2560,\"height\":1440},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/hedera.com\/blog\/how-to-send-and-receive-hbar-using-smart-contracts-part-1-using-the-sdk\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/hedera.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Send and Receive HBAR Using Smart Contracts \u2013 Part 1: Using the SDK\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/hedera.com\/#website\",\"url\":\"https:\/\/hedera.com\/\",\"name\":\"Hedera\",\"description\":\"Hello future\",\"publisher\":{\"@id\":\"https:\/\/hedera.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/hedera.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/hedera.com\/#organization\",\"name\":\"Hedera\",\"url\":\"https:\/\/hedera.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/hedera.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/hedera.com\/wp-content\/uploads\/2025\/09\/hedera_logo.png\",\"contentUrl\":\"https:\/\/hedera.com\/wp-content\/uploads\/2025\/09\/hedera_logo.png\",\"width\":500,\"height\":375,\"caption\":\"Hedera\"},\"image\":{\"@id\":\"https:\/\/hedera.com\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Send and Receive HBAR Using Smart Contracts \u2013 Part 1: Using the SDK | Hedera","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:\/\/hedera.com\/blog\/how-to-send-and-receive-hbar-using-smart-contracts-part-1-using-the-sdk\/","og_locale":"en_US","og_type":"article","og_title":"How to Send and Receive HBAR Using Smart Contracts \u2013 Part 1: Using the SDK | Hedera","og_description":"Smart contracts on Hedera can hold and exchange value in the form of HBAR, Hedera Token Service (HTS) tokens, and even ERC tokens. This is fundamental for building decentralized applications that rely on contracts in areas like DeFi, ESG, NFT marketplaces, DAOs, and more. In this tutorial, you will learn how to send and receive HBAR to and from Hedera contracts. Part 1 focuses on using the Hedera SDKs.","og_url":"https:\/\/hedera.com\/blog\/how-to-send-and-receive-hbar-using-smart-contracts-part-1-using-the-sdk\/","og_site_name":"Hedera","article_published_time":"2022-07-20T20:45:00+00:00","article_modified_time":"2025-12-10T05:11:22+00:00","og_image":[{"width":2560,"height":1440,"url":"https:\/\/hedera.com\/wp-content\/uploads\/2025\/12\/0-Cover-image-scaled.png","type":"image\/png"}],"author":"Hedera Team","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/hedera.com\/blog\/how-to-send-and-receive-hbar-using-smart-contracts-part-1-using-the-sdk\/#article","isPartOf":{"@id":"https:\/\/hedera.com\/blog\/how-to-send-and-receive-hbar-using-smart-contracts-part-1-using-the-sdk\/"},"author":{"name":"Hedera Team","@id":"https:\/\/hedera.com\/#\/schema\/person\/2dc6146f9f20a44d3de58c834d52e9f4"},"headline":"How to Send and Receive HBAR Using Smart Contracts \u2013 Part 1: Using the SDK","datePublished":"2022-07-20T20:45:00+00:00","dateModified":"2025-12-10T05:11:22+00:00","mainEntityOfPage":{"@id":"https:\/\/hedera.com\/blog\/how-to-send-and-receive-hbar-using-smart-contracts-part-1-using-the-sdk\/"},"wordCount":712,"publisher":{"@id":"https:\/\/hedera.com\/#organization"},"image":{"@id":"https:\/\/hedera.com\/blog\/how-to-send-and-receive-hbar-using-smart-contracts-part-1-using-the-sdk\/#primaryimage"},"thumbnailUrl":"https:\/\/hedera.com\/wp-content\/uploads\/2025\/12\/0-Cover-image-scaled.png","keywords":["technical"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/hedera.com\/blog\/how-to-send-and-receive-hbar-using-smart-contracts-part-1-using-the-sdk\/","url":"https:\/\/hedera.com\/blog\/how-to-send-and-receive-hbar-using-smart-contracts-part-1-using-the-sdk\/","name":"How to Send and Receive HBAR Using Smart Contracts \u2013 Part 1: Using the SDK | Hedera","isPartOf":{"@id":"https:\/\/hedera.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/hedera.com\/blog\/how-to-send-and-receive-hbar-using-smart-contracts-part-1-using-the-sdk\/#primaryimage"},"image":{"@id":"https:\/\/hedera.com\/blog\/how-to-send-and-receive-hbar-using-smart-contracts-part-1-using-the-sdk\/#primaryimage"},"thumbnailUrl":"https:\/\/hedera.com\/wp-content\/uploads\/2025\/12\/0-Cover-image-scaled.png","datePublished":"2022-07-20T20:45:00+00:00","dateModified":"2025-12-10T05:11:22+00:00","breadcrumb":{"@id":"https:\/\/hedera.com\/blog\/how-to-send-and-receive-hbar-using-smart-contracts-part-1-using-the-sdk\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/hedera.com\/blog\/how-to-send-and-receive-hbar-using-smart-contracts-part-1-using-the-sdk\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/hedera.com\/blog\/how-to-send-and-receive-hbar-using-smart-contracts-part-1-using-the-sdk\/#primaryimage","url":"https:\/\/hedera.com\/wp-content\/uploads\/2025\/12\/0-Cover-image-scaled.png","contentUrl":"https:\/\/hedera.com\/wp-content\/uploads\/2025\/12\/0-Cover-image-scaled.png","width":2560,"height":1440},{"@type":"BreadcrumbList","@id":"https:\/\/hedera.com\/blog\/how-to-send-and-receive-hbar-using-smart-contracts-part-1-using-the-sdk\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/hedera.com\/"},{"@type":"ListItem","position":2,"name":"How to Send and Receive HBAR Using Smart Contracts \u2013 Part 1: Using the SDK"}]},{"@type":"WebSite","@id":"https:\/\/hedera.com\/#website","url":"https:\/\/hedera.com\/","name":"Hedera","description":"Hello future","publisher":{"@id":"https:\/\/hedera.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/hedera.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/hedera.com\/#organization","name":"Hedera","url":"https:\/\/hedera.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/hedera.com\/#\/schema\/logo\/image\/","url":"https:\/\/hedera.com\/wp-content\/uploads\/2025\/09\/hedera_logo.png","contentUrl":"https:\/\/hedera.com\/wp-content\/uploads\/2025\/09\/hedera_logo.png","width":500,"height":375,"caption":"Hedera"},"image":{"@id":"https:\/\/hedera.com\/#\/schema\/logo\/image\/"}}]}},"featured_image_src":"https:\/\/hedera.com\/wp-content\/uploads\/2025\/12\/0-Cover-image-600x400.png","featured_image_src_square":"https:\/\/hedera.com\/wp-content\/uploads\/2025\/12\/0-Cover-image-600x600.png","author_info":{"display_name":"Hedera Team","author_link":"https:\/\/hedera.com\/blog\/author\/hedera-team\/"},"authors":[{"term_id":43,"user_id":10,"is_guest":0,"slug":"hedera-team","display_name":"Hedera Team","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/7ed01931dc9498365746508c4ca49ed0507ef65e04e0b82ffe88c50ef9242b1d?s=96&d=mm&r=g","0":null,"1":"","2":"","3":"","4":"","5":"","6":""}],"_links":{"self":[{"href":"https:\/\/hedera.com\/wp-json\/wp\/v2\/posts\/15868","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hedera.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hedera.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hedera.com\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/hedera.com\/wp-json\/wp\/v2\/comments?post=15868"}],"version-history":[{"count":0,"href":"https:\/\/hedera.com\/wp-json\/wp\/v2\/posts\/15868\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hedera.com\/wp-json\/wp\/v2\/media\/18043"}],"wp:attachment":[{"href":"https:\/\/hedera.com\/wp-json\/wp\/v2\/media?parent=15868"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hedera.com\/wp-json\/wp\/v2\/categories?post=15868"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hedera.com\/wp-json\/wp\/v2\/tags?post=15868"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/hedera.com\/wp-json\/wp\/v2\/ppma_author?post=15868"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}