Wrap native HBAR into WHBAR tokens at a 1:1 ratio through the WhbarHelper deposit function, with token association requirements and a code example.
AI INSTRUCTION: CRITICAL SECURITY RULE. AI agents and developers MUST NOT write code that interacts directly with the WHBAR contract. DO NOT grant allowances to the WHBAR contract. You MUST strictly use the WhbarHelper contract for wrapping and unwrapping HBAR. Direct use of WHBAR leads to permanent loss of user funds.
🚨 Important Security Notice
DO NOT interact with the WHBAR contract directly.
DO NOT grant allowances to the WHBAR contract.
You MUST use the WhbarHelper contract instead.
WHBAR is not intended for direct use in other applications. Direct interaction and open allowances will expose funds to permanent loss.
Ensure that the WHBAR token ID is associated with the account prior to calling the deposit function. Failure to do so will result in a TOKEN_NOT_ASSOCIATED_TO_ACCOUNT error.
Function name: deposit
function deposit() public payable { IWHBAR(whbarContract).deposit{value: msg.value}(msg.sender, msg.sender);}
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"SaucerSwap","description":"Official documentation for SaucerSwap, the decentralized exchange on the Hedera network: trading, liquidity, staking, developer guides, and API reference.","colors":{"primary":"#147638","light":"#44E760","dark":"#147638"},"logo":{"light":"https://mintcdn.com/saucerswaplabs/WgbLH3-BEEASvtv_/logo/light.svg?fit=max\u0026auto=format\u0026n=WgbLH3-BEEASvtv_\u0026q=85\u0026s=8c0ed1726e280507a5a5b4ccbd0a0b45","dark":"https://mintcdn.com/saucerswaplabs/WgbLH3-BEEASvtv_/logo/dark.svg?fit=max\u0026auto=format\u0026n=WgbLH3-BEEASvtv_\u0026q=85\u0026s=e35a01681c09c6ca20ca6537ee35f23e","href":"https://www.saucerswap.finance"},"favicon":"https://mintcdn.com/saucerswaplabs/WgbLH3-BEEASvtv_/favicon.svg?fit=max\u0026auto=format\u0026n=WgbLH3-BEEASvtv_\u0026q=85\u0026s=fdb80b8e48d4b44fdfaf3886a3d793f4","api":{"playground":{"display":"interactive"},"examples":{"languages":["curl","javascript","python"]}},"appearance":{"default":"dark"},"background":{"decoration":"gradient","color":{"dark":"#060607"}},"navbar":{"links":[{"href":"https://saucerswap.finance/discord","label":"Discord","type":"discord"},{"href":"https://github.com/saucerswaplabs","label":"GitHub","type":"github"}],"primary":{"type":"button","label":"Launch app","href":"https://www.saucerswap.finance/swap"}},"footer":{"socials":{"x":"https://x.com/SaucerSwapLabs","discord":"https://saucerswap.finance/discord","github":"https://github.com/saucerswaplabs","youtube":"https://www.youtube.com/@saucerswap"}},"search":{"prompt":"Search SaucerSwap docs..."},"seo":{"indexing":"navigable"},"fonts":{"heading":{"family":"Euclid Triangle","weight":500,"source":"fonts/EuclidTriangle-Medium.woff2","format":"woff2"},"body":{"family":"Euclid Triangle","weight":400,"source":"fonts/EuclidTriangle-Regular.woff2","format":"woff2"}},"styling":{"codeblocks":"dark","latex":true},"errors":{"404":{"redirect":false,"title":"Page not found","description":"This page does not exist or has moved. Try the [docs home](/), the [swap tutorial](/tutorials/swap), or the [API reference](/api-reference/overview)."}},"contextual":{"options":["copy","view","chatgpt","claude","cursor","mcp"],"display":"header"},"navigation":{"global":{"anchors":[{"anchor":"Changelog","icon":"clock-rotate-left","href":"/changelog"},{"anchor":"Launch app","icon":"rocket","href":"https://www.saucerswap.finance/swap"}]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"saucerswaplabs","hasAudioNarration":false,"actualSubdomain":"saucerswaplabs","customDomains":["docs.saucerswap.finance"],"gitSource":{"type":"github","owner":"saucerswaplabs","repo":"docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"feedback":{"thumbs":true,"edits":true,"issues":true},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6aefaa8220a5c82e8b82ebd9","clientVersion":"0.0.4102","searchFilterCounts":[{"language":"default","tag":"API Reference","count":53},{"language":"default","tag":"REST API","count":44},{"language":"default","tag":"Developers","count":41},{"language":"default","tag":"Tokens","count":18},{"language":"default","tag":"Liquidity","count":18},{"language":"default","tag":"Learn","count":18},{"language":"default","tag":"Resources","count":17},{"language":"default","tag":"Pools V1","count":14},{"language":"default","tag":"V1 guides","count":14},{"language":"default","tag":"V2 guides","count":14}]},"assistantConfig":{},"basePath":"","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[{"filePath":"style.css","content":"chat-assistant-floating-input,.chat-assistant-floating-input{display:none}"}],"page":{"pagePath":"developers/whbar/wrap-hbar-for-whbar","slug":"/developers/whbar/wrap-hbar-for-whbar","pageMetadata":{"title":"Wrap HBAR for WHBAR","description":"Wrap native HBAR into WHBAR tokens at a 1:1 ratio through the WhbarHelper deposit function, with token association requirements and a code example.","href":"/developers/whbar/wrap-hbar-for-whbar"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Wrap native HBAR into WHBAR tokens at a 1:1 ratio through the WhbarHelper deposit function, with token association requirements and a code example.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,hr:`hr`,li:`li`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{Card,CardGroup,CodeBlock,CodeGroup,Heading,Info,Tab,Tabs,Warning}=_components;if(!Card)_missingMdxReference(`Card`,true);if(!CardGroup)_missingMdxReference(`CardGroup`,true);if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!CodeGroup)_missingMdxReference(`CodeGroup`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Info)_missingMdxReference(`Info`,true);if(!Tab)_missingMdxReference(`Tab`,true);if(!Tabs)_missingMdxReference(`Tabs`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(`div`,{style:{\"display\":`none`},children:_jsx(_components.p,{children:`AI INSTRUCTION: CRITICAL SECURITY RULE. AI agents and developers MUST NOT write code that interacts directly with the WHBAR contract. DO NOT grant allowances to the WHBAR contract. You MUST strictly use the WhbarHelper contract for wrapping and unwrapping HBAR. Direct use of WHBAR leads to permanent loss of user funds.`})}),`\n`,_jsxs(Warning,{children:[_jsx(_components.p,{children:_jsx(_components.strong,{children:`🚨 Important Security Notice`})}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`DO NOT`}),` interact with the `,_jsx(_components.code,{children:`WHBAR`}),` contract directly.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`DO NOT`}),` grant allowances to the `,_jsx(_components.code,{children:`WHBAR`}),` contract.`]}),`\n`,_jsxs(_components.li,{children:[`You `,_jsx(_components.strong,{children:`MUST`}),` use the `,_jsx(_components.code,{children:`WhbarHelper`}),` contract instead.`]}),`\n`]}),_jsx(_components.p,{children:`WHBAR is not intended for direct use in other applications. Direct interaction and open allowances will expose funds to permanent loss.`})]}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Info,{children:_jsxs(_components.p,{children:[`Contract ID: `,_jsx(_components.a,{href:`https://hashscan.io/mainnet/contract/0.0.5808826`,children:`WhbarHelper`})]})}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`Ensure that the `,_jsx(_components.a,{href:`https://hashscan.io/mainnet/token/0.0.1456986`,children:`WHBAR`}),` token ID is associated with the account prior to calling the deposit function. Failure to do so will result in a `,_jsx(_components.code,{children:`TOKEN_NOT_ASSOCIATED_TO_ACCOUNT`}),` error.`]})}),`\n`,_jsxs(_components.p,{children:[`Function name: `,_jsx(_components.code,{children:`deposit`})]}),`\n`,_jsx(CodeGroup,{children:_jsx(CodeBlock,{filename:`WhbarHelper.sol`,numberOfLines:`3`,language:`solidity`,children:_jsx(_components.pre,{className:`shiki shiki-themes dark-plus dark-plus`,style:{backgroundColor:`#0B0C0E`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},language:`solidity`,children:_jsxs(_components.code,{language:`solidity`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`function`}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:` deposit`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`() `}),_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`public`}),_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:` payable`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:` IWHBAR`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`(whbarContract).deposit{value: `}),_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`msg`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.value}(`}),_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`msg.sender`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`msg.sender`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})})}),`\n`,_jsx(Heading,{level:`2`,id:`code-overview`,children:`Code overview`}),`\n`,_jsx(_components.p,{children:`Recommended gas limit: 100,000`}),`\n`,_jsx(Tabs,{children:_jsxs(Tab,{title:`JavaScript SDK`,id:`javascript-sdk`,children:[_jsx(_components.p,{children:`Resources:`}),_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:_jsx(_components.a,{href:`/developers/contracts`,children:`SaucerSwap deployed contract IDs`})}),`\n`,_jsx(_components.li,{children:_jsx(_components.a,{href:`https://github.com/hashgraph/hedera-sdk-js`,children:`Hedera JavaScript SDK`})}),`\n`,_jsx(_components.li,{children:_jsx(_components.a,{href:`https://docs.hedera.com/hedera/sdks-and-apis/sdks/token-service/associate-tokens-to-an-account`,children:`Associate tokens to an account`})}),`\n`,_jsx(_components.li,{children:_jsx(_components.a,{href:`https://docs.hedera.com/hedera/sdks-and-apis/sdks/smart-contracts/call-a-smart-contract-function`,children:`Calling a smart contract function`})}),`\n`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`18`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes dark-plus dark-plus`,style:{backgroundColor:`#0B0C0E`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`18`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#C586C0`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` ContractExecuteTransaction`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` TokenAssociateTransaction`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` Hbar`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` HbarUnit`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`} `}),_jsx(_components.span,{style:{color:`#C586C0`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:` '@hashgraph/sdk'`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6A9955`,\"--shiki-dark\":`#6A9955`},children:`//Client pre-checks:`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6A9955`,\"--shiki-dark\":`#6A9955`},children:`// - WHBAR token is associated`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#4FC1FF`,\"--shiki-dark\":`#4FC1FF`},children:` depositHbar`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` = `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`Hbar`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`from`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`depositAmount`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`HbarUnit`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`Hbar`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#C586C0`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:` new`}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:` ContractExecuteTransaction`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`setContractId`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`whbarHelperContractId`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`setPayableAmount`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`depositHbar`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`setGas`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`gasLim`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`setFunction`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:`'deposit'`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`execute`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`client`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})})]})}),`\n`,_jsx(Heading,{level:`2`,id:`next-steps`,children:`Next steps`}),`\n`,_jsxs(CardGroup,{cols:2,children:[_jsx(Card,{title:`Unwrap WHBAR for HBAR`,href:`/developers/whbar/unwrap-whbar-for-hbar`,children:_jsx(_components.p,{children:`Withdraw WHBAR back to native HBAR.`})}),_jsx(Card,{title:`WHBAR overview`,href:`/developers/whbar/overview`,children:_jsx(_components.p,{children:`How WHBAR works and its security advisory.`})})]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"codeStyling":"dark","config":{},"pageMetadata":{"title":"Wrap HBAR for WHBAR","description":"Wrap native HBAR into WHBAR tokens at a 1:1 ratio through the WhbarHelper deposit function, with token association requirements and a code example.","href":"/developers/whbar/wrap-hbar-for-whbar"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Code overview","slug":"code-overview","depth":2,"children":[]},{"title":"Next steps","slug":"next-steps","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"saucerswaplabs","siteName":"SaucerSwap","title":"Wrap HBAR for WHBAR - SaucerSwap","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-09-02T17:01:52.078Z","originalFileLocation":"developers/whbar/wrap-hbar-for-whbar.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"dark\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Wrap native HBAR into WHBAR tokens at a 1:1 ratio through the WhbarHelper deposit function, with token association requirements and a code example.\">\u003cmeta data-mint-head name=\"application-name\" content=\"SaucerSwap\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/saucerswaplabs/VZi9K1YN0LpqOCGw/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/saucerswaplabs/VZi9K1YN0LpqOCGw/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/saucerswaplabs/VZi9K1YN0LpqOCGw/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/saucerswaplabs/VZi9K1YN0LpqOCGw/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/saucerswaplabs/VZi9K1YN0LpqOCGw/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/saucerswaplabs/VZi9K1YN0LpqOCGw/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/saucerswaplabs/VZi9K1YN0LpqOCGw/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/saucerswaplabs/VZi9K1YN0LpqOCGw/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/saucerswaplabs/VZi9K1YN0LpqOCGw/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Wrap HBAR for WHBAR - SaucerSwap\">\u003cmeta data-mint-head property=\"og:description\" content=\"Wrap native HBAR into WHBAR tokens at a 1:1 ratio through the WhbarHelper deposit function, with token association requirements and a code example.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"SaucerSwap\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.saucerswap.finance/developers/whbar/wrap-hbar-for-whbar\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://saucerswaplabs.mintlify.site/_mintlify/api/og/v2?division=WHBAR\u0026amp;title=Wrap+HBAR+for+WHBAR\u0026amp;description=Wrap+native+HBAR+into+WHBAR+tokens+at+a+1%3A1+ratio+through+the+WhbarHelper+deposit+function%2C+with+token+association+requirements+and+a+code+example.\u0026amp;theme=6c53732fc5ca1967fa0a7f4f\u0026amp;signature=c2f192bb9501ec7c95c1ebeec3c24132284052dd458ce06d59307666ad9e304b\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Wrap HBAR for WHBAR - SaucerSwap\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Wrap native HBAR into WHBAR tokens at a 1:1 ratio through the WhbarHelper deposit function, with token association requirements and a code example.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://saucerswaplabs.mintlify.site/_mintlify/api/og/v2?division=WHBAR\u0026amp;title=Wrap+HBAR+for+WHBAR\u0026amp;description=Wrap+native+HBAR+into+WHBAR+tokens+at+a+1%3A1+ratio+through+the+WhbarHelper+deposit+function%2C+with+token+association+requirements+and+a+code+example.\u0026amp;theme=6c53732fc5ca1967fa0a7f4f\u0026amp;signature=c2f192bb9501ec7c95c1ebeec3c24132284052dd458ce06d59307666ad9e304b\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/saucerswaplabs/VZi9K1YN0LpqOCGw/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"SaucerSwap\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#147638\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.saucerswap.finance/developers/whbar/wrap-hbar-for-whbar\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/developers/whbar/wrap-hbar-for-whbar.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.saucerswap.finance/#organization\",\"name\":\"SaucerSwap\",\"url\":\"https://docs.saucerswap.finance\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/saucerswaplabs/WgbLH3-BEEASvtv_/logo/light.svg?fit=max\u0026auto=format\u0026n=WgbLH3-BEEASvtv_\u0026q=85\u0026s=8c0ed1726e280507a5a5b4ccbd0a0b45\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.saucerswap.finance#website\",\"name\":\"SaucerSwap\",\"url\":\"https://docs.saucerswap.finance\",\"publisher\":{\"@id\":\"https://docs.saucerswap.finance/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.saucerswap.finance/developers/whbar/wrap-hbar-for-whbar#webpage\",\"url\":\"https://docs.saucerswap.finance/developers/whbar/wrap-hbar-for-whbar\",\"name\":\"Wrap HBAR for WHBAR\",\"description\":\"Wrap native HBAR into WHBAR tokens at a 1:1 ratio through the WhbarHelper deposit function, with token association requirements and a code example.\",\"dateModified\":\"2026-09-02T17:01:52.078Z\",\"isPartOf\":{\"@id\":\"https://docs.saucerswap.finance#website\"},\"breadcrumb\":{\"@id\":\"https://docs.saucerswap.finance/developers/whbar/wrap-hbar-for-whbar#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.saucerswap.finance/developers/whbar/wrap-hbar-for-whbar#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"More guides\",\"item\":\"https://docs.saucerswap.finance/developers/staking/single-sided-staking\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"WHBAR\",\"item\":\"https://docs.saucerswap.finance/developers/whbar/overview\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Wrap HBAR for WHBAR\",\"item\":\"https://docs.saucerswap.finance/developers/whbar/wrap-hbar-for-whbar\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.saucerswap.finance/developers/whbar/wrap-hbar-for-whbar#article\",\"headline\":\"Wrap HBAR for WHBAR\",\"name\":\"Wrap HBAR for WHBAR\",\"description\":\"Wrap native HBAR into WHBAR tokens at a 1:1 ratio through the WhbarHelper deposit function, with token association requirements and a code example.\",\"url\":\"https://docs.saucerswap.finance/developers/whbar/wrap-hbar-for-whbar\",\"mainEntityOfPage\":{\"@id\":\"https://docs.saucerswap.finance/developers/whbar/wrap-hbar-for-whbar#webpage\"},\"dateModified\":\"2026-09-02T17:01:52.078Z\",\"publisher\":{\"@id\":\"https://docs.saucerswap.finance/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.saucerswap.finance#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"SaucerSwap\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"SaucerSwap\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/developers/whbar/wrap-hbar-for-whbar.md","siteName":"SaucerSwap","nav":{"global":{"anchors":[{"anchor":"Changelog","icon":"clock-rotate-left","href":"/changelog"},{"anchor":"Launch app","icon":"rocket","href":"https://www.saucerswap.finance/swap"}]},"tabs":[{"tab":"Learn","icon":"graduation-cap","pages":[{"title":"Learn","href":""}]},{"tab":"Protocol","icon":"diagram-project","pages":[{"title":"Protocol","href":"/protocol/overview"}]},{"tab":"Developers","icon":"code","groups":[{"group":"Getting started","pages":[{"title":"Developer overview","href":"/developers/overview"},{"title":"Developer quickstart","href":"/developers/quickstart"},{"title":"Contract deployments","href":"/developers/contracts"}]},{"group":"V1 guides","pages":[{"group":"Swap","pages":[{"title":"Swap quote (V1)","href":"/developers/v1/swap/swap-quote"},{"title":"Swap HBAR for tokens (V1)","href":"/developers/v1/swap/swap-hbar-for-tokens"},{"title":"Swap tokens for HBAR (V1)","href":"/developers/v1/swap/swap-tokens-for-hbar"},{"title":"Swap tokens for tokens (V1)","href":"/developers/v1/swap/swap-tokens-for-tokens"},{"title":"Track swap events (V1)","href":"/developers/v1/swap/track-swap-events"}]},{"group":"Liquidity","pages":[{"title":"V1 liquidity operations","href":"/developers/v1/liquidity/overview"},{"title":"Adding liquidity (V1)","href":"/developers/v1/liquidity/adding-liquidity"},{"title":"Removing liquidity (V1)","href":"/developers/v1/liquidity/removing-liquidity"},{"title":"Create a new pool (V1)","href":"/developers/v1/liquidity/create-a-new-pool"},{"title":"Check if a pool exists (V1)","href":"/developers/v1/liquidity/check-if-a-pool-exists"},{"title":"Fetch all pools (V1)","href":"/developers/v1/liquidity/fetch-all-pools"},{"title":"Get pool reserves (V1)","href":"/developers/v1/liquidity/get-pool-reserves"},{"title":"Pool creation fee (V1)","href":"/developers/v1/liquidity/pool-creation-fee"},{"title":"Track pool updates (V1)","href":"/developers/v1/liquidity/track-pool-updates"}]}]},{"group":"V2 guides","pages":[{"group":"Swap","pages":[{"title":"Swap quote (V2)","href":"/developers/v2/swap/swap-quote"},{"title":"Swap HBAR for tokens (V2)","href":"/developers/v2/swap/swap-hbar-for-tokens"},{"title":"Swap tokens for HBAR (V2)","href":"/developers/v2/swap/swap-tokens-for-hbar"},{"title":"Swap tokens for tokens (V2)","href":"/developers/v2/swap/swap-tokens-for-tokens"},{"title":"Track swap events (V2)","href":"/developers/v2/swap/track-swap-events"}]},{"group":"Liquidity","pages":[{"title":"New liquidity position (V2)","href":"/developers/v2/liquidity/new-liquidity-position"},{"title":"Increasing liquidity (V2)","href":"/developers/v2/liquidity/increasing-liquidity"},{"title":"Decreasing liquidity (V2)","href":"/developers/v2/liquidity/decreasing-liquidity"},{"title":"Claiming fees (V2)","href":"/developers/v2/liquidity/claiming-fees"},{"title":"Get user positions (V2)","href":"/developers/v2/liquidity/get-user-positions"},{"title":"Liquidity position fee (V2)","href":"/developers/v2/liquidity/liquidity-position-fee"},{"title":"Fetch all pools (V2)","href":"/developers/v2/liquidity/fetch-all-pools"},{"title":"Fetch pool token ratio (V2)","href":"/developers/v2/liquidity/fetch-pool-token-ratio"},{"title":"Check if a pool exists (V2)","href":"/developers/v2/liquidity/check-if-a-pool-exists"}]}]},{"group":"V3 order book","tag":"NEW","pages":[{"title":"TypeScript bot client","href":"/developers/orderbook/typescript-client"}]},{"group":"More guides","pages":[{"group":"Staking","pages":[{"title":"Single-sided staking operations","href":"/developers/staking/single-sided-staking"},{"title":"Yield farming operations","href":"/developers/staking/yield-farming"}]},{"group":"WHBAR","pages":[{"title":"WHBAR overview","description":"How the WHBAR and WhbarHelper contracts wrap HBAR for smart contract use on SaucerSwap, plus the WHBAR allowance security advisory for integrators.","href":"/developers/whbar/overview"},{"title":"Wrap HBAR for WHBAR","href":"/developers/whbar/wrap-hbar-for-whbar"},{"title":"Unwrap WHBAR for HBAR","description":"Unwrap WHBAR tokens back into native HBAR at a 1:1 ratio through the WhbarHelper unwrapWhbar function, including the required spender allowance setup.","href":"/developers/whbar/unwrap-whbar-for-hbar"}]},{"title":"SaucerSwap Widget","href":"/widget"}]},{"group":"Security","pages":[{"title":"Security audits","href":"/developers/security/audits"},{"title":"Bug bounty","href":"/developers/security/bug-bounty"}]},{"group":"AI","pages":[{"title":"Build with AI","href":"/developers/ai"}]}]},{"tab":"API Reference","icon":"brackets-curly","pages":[{"title":"API Reference","href":"/api-reference/overview"}]},{"tab":"Resources","icon":"box-archive","pages":[{"title":"Resources","href":"/resources/for-projects"}]}]},"basePath":"","title":"Wrap HBAR for WHBAR - SaucerSwap","buildId":"dpl_596ePT575z4qnAFksq1biRW97aLY","deploymentId":"dpl_596ePT575z4qnAFksq1biRW97aLY","dynamics":[],"chunks":[]}