{"id":11236,"date":"2023-04-06T12:49:42","date_gmt":"2023-04-06T12:49:42","guid":{"rendered":"https:\/\/cheesecakelabs.com\/blog\/"},"modified":"2024-02-23T15:06:32","modified_gmt":"2024-02-23T15:06:32","slug":"how-to-use-stellar-soroban-to-write-a-bond-smart-contract","status":"publish","type":"post","link":"https:\/\/cheesecakelabs.com\/blog\/how-to-use-stellar-soroban-to-write-a-bond-smart-contract\/","title":{"rendered":"How To Use Stellar\u2019s Soroban To Write a Bond Smart Contract"},"content":{"rendered":"\n<p>Stellar&#8217;s new smart contracts platform, <a href=\"https:\/\/soroban.stellar.org\/\">Soroban<\/a>, gives the <a href=\"https:\/\/cheesecakelabs.com\/blog\/stellar-network\/\" target=\"_blank\" rel=\"noreferrer noopener\">Stellar network<\/a> more flexibility to support various use cases. With it, it\u2019s possible to implement custom business logic on-chain that was previously limited to classic operations.<\/p>\n\n\n\n<p>In this post, we\u2019ll show you how to create a Stellar smart contract and discuss how best to use Stellar\u2019s <a href=\"https:\/\/cheesecakelabs.com\/blog\/stellar-soroban\/\" target=\"_blank\" rel=\"noreferrer noopener\">Soroban<\/a> and its flexible features.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Table of Contents<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#Bond-tokens\">Bond tokens<\/a><\/li>\n\n\n\n<li><a href=\"#ERC-20-Tokens\">ERC-20 Tokens<\/a><\/li>\n\n\n\n<li><a href=\"#Writing-the-smart-contract\">Writing the smart contract<\/a>\n<ul class=\"wp-block-list\">\n<li><a href=\"#Initialization\">Initialization<\/a><\/li>\n\n\n\n<li><a href=\"#Buy-bonds\">Buy bonds<\/a><\/li>\n\n\n\n<li><a href=\"#Withdraw\">Withdraw<\/a><\/li>\n\n\n\n<li><a href=\"#Enable-cash-out\">Enable cash out<\/a><\/li>\n\n\n\n<li><a href=\"#Cash-out\">Cash out<\/a><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><a href=\"#Learn-more-about-the-blockchain-with-Cheesecake-Labs\">Learn more about the blockchain with Cheesecake Labs<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"Bond-tokens\"><strong>Bond tokens<\/strong><\/h2>\n\n\n\n<p>In finance, bonds are securities in which the issuer owes the holder a debt. After a period of time, the bond issuer pays all holders the bond&#8217;s value and the interest rate.<\/p>\n\n\n\n<p>This is beneficial for the users, who profit from the purchase of bonds, and for the issuer, who can conduct business using the money used to buy the bonds before they\u2019re paid out.<\/p>\n\n\n\n<p>For our use case, we will treat the bonds as tokens, which users can buy and trade.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"ERC-20-Tokens\"><strong>ERC-20 Tokens<\/strong><\/h2>\n\n\n\n<p>The ERC-20 is a popular standard of Fungible Tokens used to ensure that each token is created using the same methods as another token.<\/p>\n\n\n\n<p>It is an essential tool for interoperating with other contracts because it allows integration with the token without needing to know the details of its implementation.<\/p>\n\n\n\n<p>For our use case, it will represent our bond token and the payment token, which will be used to buy bonds and pay debts.<\/p>\n\n\n\n<p>The Soroban interface based on the ERC-20 token standard can be found in the official<a href=\"https:\/\/soroban.stellar.org\/docs\/common-interfaces\/token\" target=\"_blank\" rel=\"noreferrer noopener\"> Soroban documentation<\/a>. We are using this compiled interface, which can be found in the <a href=\"https:\/\/github.com\/stellar\/soroban-examples\/blob\/main\/soroban_token_spec.wasm\" target=\"_blank\" rel=\"noreferrer noopener\">Soroban examples repository<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"Writing-the-smart-contract\"><strong>Writing the smart contract<\/strong><\/h2>\n\n\n\n<p>Before we begin, let&#8217;s take a look at the logic of our smart contract.<\/p>\n\n\n\n<p>There are two types of users: the <strong>Admin<\/strong>, who manages the contract, and the <strong>Users<\/strong>, who can buy the bonds and cash out when allowed.<\/p>\n\n\n\n<p>The administrator is responsible for managing the contract and determining when a bond can be bought, how long it will appreciate in value, and when users can withdraw their money.<\/p>\n\n\n\n<p>Some extra management actions are also allowed, like managing which users can buy the bonds or pausing purchases temporarily. Finally, the admin can also withdraw the money received to pay the bonds.<\/p>\n\n\n\n<p>The users can perform two actions \u2014 purchasing a bond and cashing out. They can only perform these actions can in the periods set by the admin and if they have the necessary authorization.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"346\" src=\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/04\/image-1200x346.jpg\" alt=\"\" class=\"wp-image-11237\" srcset=\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/04\/image-1200x346.jpg 1200w, https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/04\/image-600x173.jpg 600w, https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/04\/image-768x222.jpg 768w, https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/04\/image-1536x443.jpg 1536w, https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/04\/image-760x219.jpg 760w, https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/04\/image.jpg 2000w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure>\n\n\n\n<p>The appreciation of the bond occurs over a period determined by the administrator, bound by the start date and the end date. The purchase period of the bond is not directly linked to this period and can occur at different intervals.<\/p>\n\n\n\n<p>Contract attributes like which tokens will be used, interest rate, interest type, and interest time interval are customizable and are set at initialization. We will discuss this in more detail in the following sections.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"Initialization\"><strong>Initialization<\/strong><\/h3>\n\n\n\n<p>The<em> initialize<\/em> function sets the contract attributes right after its deployment. We won&#8217;t go too deep into its implementation, but it is essential to understand the parameters it receives.<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:100%\"><pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"Rust\" data-shcb-language-slug=\"rust\"><span><code class=\"hljs language-rust\"><span class=\"hljs-keyword\">impl<\/span> BondTrait <span class=\"hljs-keyword\">for<\/span> Bond {\n\t...\n\t<span class=\"hljs-function\"><span class=\"hljs-keyword\">fn<\/span> <span class=\"hljs-title\">initialize<\/span><\/span>(\n      e: Env,\n      admin: Identifier,\n      payment_token_id: BytesN&lt;<span class=\"hljs-number\">32<\/span>&gt;,\n      bond_token_name: Bytes,\n      bond_token_symbol: Bytes,\n      bond_token_decimals: <span class=\"hljs-built_in\">u32<\/span>,\n      price: <span class=\"hljs-built_in\">i128<\/span>,\n      fee_rate: <span class=\"hljs-built_in\">i128<\/span>,\n      fee_days_interval: <span class=\"hljs-built_in\">u64<\/span>,\n      fee_type: InterestType,\n      initial_amount: <span class=\"hljs-built_in\">i128<\/span>,\n  ) {\n\t\t...\n\t}\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Rust<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">rust<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre><\/div>\n<\/div>\n\n\n\n<p>Some considerations about these parameters:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The <code>payment_token_id<\/code> represents the payment token contract address.<\/li>\n\n\n\n<li>The <code>bond_token_\u2026<\/code> parameters define the attributes of the bond token. We get this instead of an address because we will deploy this token during initialization. This way, the current contract is the initial administrator of the token contract and can perform privileged functions such as mint and burn.<\/li>\n\n\n\n<li>The <code>price<\/code> determines how much each unit of bond token is worth in terms of payment tokens.<\/li>\n\n\n\n<li>The <code>fee_rate <\/code>represents the valuation rate of the bond token. That is, the interest rate applied to each time interval. It is expected to receive this rate multiplied by 1000 to allow for greater granularity of this value since Soroban does not support decimal numbers. This means that for an interest rate of 15%, the <code>fee_rate<\/code> parameter should be <code>150<\/code> (0.15 * 1000).<\/li>\n\n\n\n<li>The <code>fee_days_interval<\/code> represents the interval in days that the interest rate will be applied to the bond token value. Since we will use timestamps to calculate the time differences, we are converting and saving this interval in seconds to make the calculations easier.<\/li>\n\n\n\n<li>The <code>fee_type<\/code><em> <\/em>defines the type of interest that will be applied to each interval: simple or compound. This is an additional attribute to make the contract more flexible to different use cases and can be changed depending on the business logic.<\/li>\n\n\n\n<li>The<em> <\/em><code>initial_amount<\/code> defines how many bond tokens will be minted at that moment.<\/li>\n<\/ul>\n\n\n\n<p>Next, we will dive a little deeper into some of the core components of the contract, starting with the <code>buy<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"Buy-bonds\"><strong>Buy bonds<\/strong><\/h3>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:100%\"><pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"Rust\" data-shcb-language-slug=\"rust\"><span><code class=\"hljs language-rust\"><span class=\"hljs-keyword\">impl<\/span> BondTrait <span class=\"hljs-keyword\">for<\/span> Bond {\n\t...\n\t<span class=\"hljs-function\"><span class=\"hljs-keyword\">fn<\/span> <span class=\"hljs-title\">buy<\/span><\/span>(e: Env, amount: <span class=\"hljs-built_in\">i128<\/span>) {\n\t    <span class=\"hljs-keyword\">if<\/span> read_state(&amp;e) != State::Available {\n\t        panic_with_error!(&amp;e, Error::NotAvailable)\n\t    }\n\t    <span class=\"hljs-keyword\">if<\/span> !check_user(&amp;e, &amp;(e.invoker().into())) {\n\t        panic_with_error!(&amp;e, Error::UserNotAllowed)\n\t    }\n\t    increase_supply(&amp;e, amount);\n\t    <span class=\"hljs-comment\">\/\/ Total will be the Bond amount multiplied by Bond price<\/span>\n\t    <span class=\"hljs-keyword\">let<\/span> total = current_price(&amp;e) * amount;\n\t    ...\n\t}\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Rust<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">rust<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre><\/div>\n<\/div>\n\n\n\n<p>For a user to be able to buy a bond, the purchase must be available, and the administrator must authorize the user. If the user satisfies these requirements, the supply (the amount of bond sold) increases by the amount the user intends to buy.<\/p>\n\n\n\n<p>After this, it is necessary to calculate the bond&#8217;s current price. This is because the bond starts at a certain price but gets more expensive as time passes. Let&#8217;s look at the <code>current_price<\/code><em> <\/em>function that performs this calculation.<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:100%\"><pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"Rust\" data-shcb-language-slug=\"rust\"><span><code class=\"hljs language-rust\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">fn<\/span> <span class=\"hljs-title\">current_price<\/span><\/span>(e: &amp;Env) -&gt; <span class=\"hljs-built_in\">i128<\/span> {\n    <span class=\"hljs-keyword\">let<\/span> <span class=\"hljs-keyword\">mut<\/span> end_time = read_end_time(&amp;e);\n    <span class=\"hljs-keyword\">let<\/span> now = e.ledger().timestamp();\n    <span class=\"hljs-comment\">\/\/ If the end date has not passed yet<\/span>\n    <span class=\"hljs-keyword\">if<\/span> now &lt; end_time {\n        end_time = now;\n    }\n    <span class=\"hljs-keyword\">let<\/span> initial_price = read_price(&amp;e);\n    <span class=\"hljs-comment\">\/\/ Calculates the amount of time intervals that have passed<\/span>\n    <span class=\"hljs-keyword\">let<\/span> time = (end_time - read_init_time(&amp;e)) \/ read_fee_interval(&amp;e);\n    <span class=\"hljs-comment\">\/\/ If no time interval has passed, the price does not change<\/span>\n    <span class=\"hljs-keyword\">if<\/span> time == <span class=\"hljs-number\">0<\/span> {\n        <span class=\"hljs-keyword\">return<\/span> initial_price;\n    }\n    <span class=\"hljs-keyword\">let<\/span> fee_type = read_fee_type(e);\n    <span class=\"hljs-keyword\">match<\/span> fee_type {\n        InterestType::Simple =&gt; {\n            <span class=\"hljs-keyword\">return<\/span> initial_price + (initial_price * (time <span class=\"hljs-keyword\">as<\/span> <span class=\"hljs-built_in\">i128<\/span>) * read_fee_rate(&amp;e)) \/ <span class=\"hljs-number\">1000<\/span>;\n        }\n        InterestType::Compound =&gt; {\n            <span class=\"hljs-keyword\">let<\/span> fees = <span class=\"hljs-number\">1000<\/span> + read_fee_rate(&amp;e);\n            <span class=\"hljs-keyword\">return<\/span> initial_price * (fees.pow(time <span class=\"hljs-keyword\">as<\/span> <span class=\"hljs-built_in\">u32<\/span>)) \/ <span class=\"hljs-number\">1000_i128<\/span>.pow(time <span class=\"hljs-keyword\">as<\/span> <span class=\"hljs-built_in\">u32<\/span>);\n        }\n    }\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Rust<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">rust<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre><\/div>\n<\/div>\n\n\n\n<p>Here we need to calculate how much time has elapsed between the bond\u2019s start date and now unless the end date has already passed, in which case, we will calculate the time between the start date and the end date.<\/p>\n\n\n\n<p>With the time calculated, we need to determine how many time intervals have passed. For example, if our interval is one week, and 40 days have passed since the starting date, this value will be equal to 40 mod 7 = 5. <strong>In Soroban, all divisions are integer divisions<\/strong>, so we don&#8217;t have to worry about the modulo.<\/p>\n\n\n\n<p>Our contract gives the flexibility to apply simple or compound interest, depending on the choice made at initialization. The calculation for each type of interest follows the standard logic of the mathematical interest formula, except for the 1000 factor. The factor 1000 added in each of the operations neutralizes our interest rate, which is multiplied by this value.<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:100%\"><pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"Rust\" data-shcb-language-slug=\"rust\"><span><code class=\"hljs language-rust\"><span class=\"hljs-keyword\">impl<\/span> BondTrait <span class=\"hljs-keyword\">for<\/span> Bond {\n\t...\n\t<span class=\"hljs-function\"><span class=\"hljs-keyword\">fn<\/span> <span class=\"hljs-title\">buy<\/span><\/span>(e: Env, amount: <span class=\"hljs-built_in\">i128<\/span>) {\n\t    ...\n\t    <span class=\"hljs-comment\">\/\/ Total will be the Bond amount multiplied by Bond price<\/span>\n\t    <span class=\"hljs-keyword\">let<\/span> total = current_price(&amp;e) * amount;\n\t    <span class=\"hljs-keyword\">let<\/span> invoker: Identifier = e.invoker().into();\n\t    transfer_from_account_to_contract(&amp;e, &amp;read_payment_token(&amp;e), &amp;invoker.clone(), &amp;total);\n\t    transfer_from_contract_to_account(&amp;e, &amp;read_bond_token_id(&amp;e), &amp;invoker.clone(), &amp;amount);\n\t}\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Rust<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">rust<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Returning to the buy function, after calculating the bond&#8217;s current price and multiplying it by the amount the user wants to buy, we get the number of payment tokens the contract should receive from the user.<\/p>\n\n\n\n<p>The function <code>transfer_from_account_to_contract<\/code> performs the <code>transfer_from<\/code> token function from the user account to the contract account.<\/p>\n\n\n\n<p>This implies the user must have allowed the contract to take this payment token amount from them. Otherwise, an error will be issued, and the user will not succeed in buying the bonds.<\/p>\n\n\n\n<p>After the contract receives the user&#8217;s payment tokens, it sends the purchased bonds from their balance to the user&#8217;s account using the function <code>transfer_from_contract_to_account<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"Withdraw\"><strong>Withdraw<\/strong><\/h3>\n\n\n\n<p>The contract allows the administrator to withdraw user payment tokens to their account. The admin can use these tokens as they wish while cash out is not enabled.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"Rust\" data-shcb-language-slug=\"rust\"><span><code class=\"hljs language-rust\"><span class=\"hljs-keyword\">impl<\/span> BondTrait <span class=\"hljs-keyword\">for<\/span> Bond {\n\t...\n\t<span class=\"hljs-function\"><span class=\"hljs-keyword\">fn<\/span> <span class=\"hljs-title\">withdraw<\/span><\/span>(e: Env, amount: <span class=\"hljs-built_in\">i128<\/span>) {\n\t    check_admin(&amp;e, &amp;Signature::Invoker);\n\t    <span class=\"hljs-keyword\">if<\/span> read_state(&amp;e) == State::CashOutEn {\n\t        panic_with_error!(&amp;e, Error::AlreadyCashOutEn)\n\t    }\n\t    transfer_from_contract_to_account(\n\t        &amp;e,\n\t        &amp;read_payment_token(&amp;e),\n\t        &amp;e.invoker().clone().into(),\n\t        &amp;amount,\n\t    );\n\t}\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Rust<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">rust<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\" id=\"Enable-cash-out\"><strong>Enable cash out<\/strong><\/h3>\n\n\n\n<p>Certain state conditions must be met to enable cash out, and the bond&#8217;s valuation period must be over. But the most important requirement here is that the contract must have in its balance the payment tokens needed to pay all the users who have purchased bonds with the bond&#8217;s current price.<\/p>\n\n\n\n<p>Therefore, the administrator must pay the contract the required amount before calling this function. This can be done via the transfer function of the payment token contract.<\/p>\n\n\n\n<p>Once this state is enabled, the payment tokens in the contract can no longer be withdrawn by the admin.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"Rust\" data-shcb-language-slug=\"rust\"><span><code class=\"hljs language-rust\"><span class=\"hljs-keyword\">impl<\/span> BondTrait <span class=\"hljs-keyword\">for<\/span> Bond {\n\t...\n\t<span class=\"hljs-function\"><span class=\"hljs-keyword\">fn<\/span> <span class=\"hljs-title\">en_csh_out<\/span><\/span>(e: Env) {\n\t    check_admin(&amp;e, &amp;Signature::Invoker);\n\t\n\t    <span class=\"hljs-keyword\">let<\/span> state = read_state(&amp;e);\n\t    <span class=\"hljs-keyword\">if<\/span> state != State::Available &amp;&amp; state != State::Paused {\n\t        panic_with_error!(&amp;e, Error::NotAvailable)\n\t    }\n\t\n\t    <span class=\"hljs-comment\">\/\/ Check if end time has passed<\/span>\n\t    <span class=\"hljs-keyword\">if<\/span> e.ledger().timestamp() &lt; read_end_time(&amp;e) {\n\t        panic_with_error!(&amp;e, Error::EndTimeNotPassed)\n\t    }\n\t\n\t    <span class=\"hljs-comment\">\/\/ Check if the contract has the amount of payment tokens to<\/span>\n\t    <span class=\"hljs-comment\">\/\/ pay the users<\/span>\n\t    <span class=\"hljs-keyword\">let<\/span> amount_payment = current_price(&amp;e) * read_supply(&amp;e);\n\t    <span class=\"hljs-keyword\">let<\/span> contract_balance = token_balance(\n\t        &amp;e,\n\t        &amp;read_payment_token(&amp;e),\n\t        &amp;Identifier::Contract(e.current_contract()),\n\t    );\n\t\n\t    <span class=\"hljs-keyword\">if<\/span> contract_balance &lt; amount_payment {\n\t        panic_with_error!(&amp;e, Error::NotEnoughTokens)\n\t    }\n\t\n\t    write_state(&amp;e, State::CashOutEn);\n\t}\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Rust<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">rust<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre><\/div>\n<\/div>\n\n\n\n<p>After the conditions are met, the contract state is changed to allow cash out.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"Cash-out\"><strong>Cash out<\/strong><\/h3>\n\n\n\n<p>The cash out is performed by reading the user&#8217;s balance and checking how many bonds they have on their account. The amount of payment tokens transferred from the contract to the user&#8217;s account is the number of bonds they own multiplied by the bond&#8217;s current value.<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:100%\"><pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"Rust\" data-shcb-language-slug=\"rust\"><span><code class=\"hljs language-rust\"><span class=\"hljs-keyword\">impl<\/span> BondTrait <span class=\"hljs-keyword\">for<\/span> Bond {\n\t...\n\t<span class=\"hljs-function\"><span class=\"hljs-keyword\">fn<\/span> <span class=\"hljs-title\">cash_out<\/span><\/span>(e: Env) {\n\t    <span class=\"hljs-keyword\">if<\/span> read_state(&amp;e) != State::CashOutEn {\n\t        panic_with_error!(&amp;e, Error::NotCashOutEn)\n\t    }\n\t\n\t    <span class=\"hljs-keyword\">let<\/span> invoker: Identifier = e.invoker().into();\n\t\n\t    <span class=\"hljs-comment\">\/\/ Get the user Bond Token balance<\/span>\n\t    <span class=\"hljs-keyword\">let<\/span> bond_balance = token_balance(&amp;e, &amp;read_bond_token_id(&amp;e), &amp;invoker.clone());\n\t    <span class=\"hljs-comment\">\/\/ Calculates amount of payment token<\/span>\n\t    <span class=\"hljs-keyword\">let<\/span> total_payment = bond_balance * current_price(&amp;e);\n\t    <span class=\"hljs-comment\">\/\/ Decrease supply<\/span>\n\t    decrease_supply(&amp;e, bond_balance);\n\t    <span class=\"hljs-comment\">\/\/ Transfer amount of payment tokens from contract to user<\/span>\n\t    transfer_from_contract_to_account(\n\t        &amp;e,\n\t        &amp;&amp;read_payment_token(&amp;e),\n\t        &amp;invoker.clone(),\n\t        &amp;total_payment,\n\t    );\n\t    <span class=\"hljs-comment\">\/\/ Burn all the Bond tokens from user<\/span>\n\t    burn_token(\n\t        &amp;e,\n\t        &amp;read_bond_token_id(&amp;e),\n\t        &amp;Signature::Invoker,\n\t        &amp;invoker,\n\t        &amp;bond_balance,\n\t    );\n\t}\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Rust<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">rust<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre><\/div>\n<\/div>\n\n\n\n<p>This implies that no matter how much the user paid for the bond, they will always get their money back at a higher price. For example, if user A bought 100 bonds and user B bought 100 bonds a few months later, both users will receive the same number of payment tokens at the cash-out.<\/p>\n\n\n\n<p>The key difference is that the profit of user A will be higher as they paid less for the bond initially than user B.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"918\" height=\"1200\" src=\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/04\/image-1-918x1200.jpg\" alt=\"\" class=\"wp-image-11239\" srcset=\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/04\/image-1-918x1200.jpg 918w, https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/04\/image-1-459x600.jpg 459w, https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/04\/image-1-768x1004.jpg 768w, https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/04\/image-1-1176x1536.jpg 1176w, https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/04\/image-1-1567x2048.jpg 1567w, https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/04\/image-1-760x993.jpg 760w, https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/04\/image-1.jpg 1650w\" sizes=\"(max-width: 918px) 100vw, 918px\" \/><\/figure>\n\n\n\n<p>After transferring the payment, the user&#8217;s bonds are burned. This transaction is only possible because the current contract is the admin of the bond token contract.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"Learn-more-about-the-blockchain-with-Cheesecake-Labs\"><strong>Learn more about the blockchain with Cheesecake Labs<\/strong><\/h2>\n\n\n\n<p>This post has outlined the core components of a bond sales contract. If you would like to explore the rest of the functions in more depth, <strong><a href=\"https:\/\/github.com\/CheesecakeLabs\/soroban-poc\/tree\/main\/bond\" target=\"_blank\" rel=\"noreferrer noopener\">you can take a look at the source code.<\/a><\/strong><\/p>\n\n\n\n<p>You can learn more about <a href=\"https:\/\/cheesecakelabs.com\/blog\/future-stellar-network\/\">the Stellar network<\/a>, <a href=\"https:\/\/cheesecakelabs.com\/blog\/cryptocurrency-wallet-development\/\">cryptocurrency wallet development<\/a>, and <a href=\"https:\/\/cheesecakelabs.com\/blog\/blockchain-guide-getting-started-blockchain-app\/\">the basics of blockchain<\/a> on the Cheesecake Labs blog. And sign up for the Cheesecake Labs newsletter to get the latest updates delivered to your inbox.<\/p>\n\n\n\n<style>\n  .libutton {\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    width: 100%;\n  }\n  .libutton > a {\n    display: flex;\n    flex-direction: column;\n    justify-content: center;\n    padding: 7px;\n    text-align: center;\n    outline: none;\n    text-decoration: none !important;\n    color: #ffffff !important;\n    width: 300px;\n    height: 40px;\n    border-radius: 0px;\n    background-color: #0157FF;\n    font-family: \"Poppins\", bold;font-size: 20px;\n  }\n<\/style>\n<div class=\"libutton\">\n<a href=\"https:\/\/www.linkedin.com\/build-relation\/newsletter-follow?entityUrn=7036416590715707392\" target=\"_blank\" rel=\"noopener\">Subscribe on LinkedIn<\/a>\n<\/div>\n\n\n\n<p>As a <a href=\"https:\/\/cheesecakelabs.com\/services\/blockchain\/\" target=\"_blank\" rel=\"noreferrer noopener\">Stellar Integration Partner<\/a>, Cheesecake Labs is an excellent choice to help you bring your ideas for blockchain projects to life.<\/p>\n\n\n\n<p><a href=\"https:\/\/cheesecakelabs.com\/contact\/\" target=\"_blank\" rel=\"noreferrer noopener\">Get in touch<\/a> and tell us about your project!<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/cheesecakelabs.com\/contact\/\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" width=\"1200\" height=\"628\" src=\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/01\/stellar-integration-partner-1200x628.png\" alt=\"four men of ckl's team at the stellar annual conference\" class=\"wp-image-11025\" srcset=\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/01\/stellar-integration-partner-1200x628.png 1200w, https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/01\/stellar-integration-partner-600x314.png 600w, https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/01\/stellar-integration-partner-768x402.png 768w, https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/01\/stellar-integration-partner-1536x804.png 1536w, https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/01\/stellar-integration-partner-2048x1072.png 2048w, https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/01\/stellar-integration-partner-760x398.png 760w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/a><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Stellar&#8217;s new smart contracts platform, Soroban, gives the Stellar network more flexibility to support various use cases. With it, it\u2019s possible to implement custom business logic on-chain that was previously limited to classic operations. In this post, we\u2019ll show you how to create a Stellar smart contract and discuss how best to use Stellar\u2019s Soroban [&hellip;]<\/p>\n","protected":false},"author":81,"featured_media":11245,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[432,1165],"tags":[1188,1230,1231,1203],"class_list":["post-11236","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-engineering","category-blockchain","tag-blockchain","tag-smart-contract","tag-soroban","tag-stellar-network"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Step-by-Step: Writing a Bond Smart Contract with Stellar&#039;s Soroban<\/title>\n<meta name=\"description\" content=\"Learn how to create a Stellar smart contract with our guide using Soroban effectively and takings advantage of its flexible features.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cheesecakelabs.com\/blog\/how-to-use-stellar-soroban-to-write-a-bond-smart-contract\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Step-by-Step: Writing a Bond Smart Contract with Stellar&#039;s Soroban\" \/>\n<meta property=\"og:description\" content=\"Learn how to create a Stellar smart contract with our guide using Soroban effectively and takings advantage of its flexible features.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cheesecakelabs.com\/blog\/how-to-use-stellar-soroban-to-write-a-bond-smart-contract\/\" \/>\n<meta property=\"og:site_name\" content=\"Cheesecake Labs\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/cheesecakelabs\" \/>\n<meta property=\"article:published_time\" content=\"2023-04-06T12:49:42+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-02-23T15:06:32+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/04\/stellar-sorobar-smart-contracts.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"860\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Cheesecake Labs\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@cheesecakelabs\" \/>\n<meta name=\"twitter:site\" content=\"@cheesecakelabs\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/how-to-use-stellar-soroban-to-write-a-bond-smart-contract\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/how-to-use-stellar-soroban-to-write-a-bond-smart-contract\/\"},\"author\":{\"name\":\"Alessandra Carneiro\"},\"headline\":\"How To Use Stellar\u2019s Soroban To Write a Bond Smart Contract\",\"datePublished\":\"2023-04-06T12:49:42+00:00\",\"dateModified\":\"2024-02-23T15:06:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/how-to-use-stellar-soroban-to-write-a-bond-smart-contract\/\"},\"wordCount\":1545,\"image\":{\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/how-to-use-stellar-soroban-to-write-a-bond-smart-contract\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/04\/stellar-sorobar-smart-contracts.jpg\",\"keywords\":[\"blockchain\",\"smart contract\",\"soroban\",\"stellar network\"],\"articleSection\":[\"Engineering\",\"Blockchain\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/how-to-use-stellar-soroban-to-write-a-bond-smart-contract\/\",\"url\":\"https:\/\/cheesecakelabs.com\/blog\/how-to-use-stellar-soroban-to-write-a-bond-smart-contract\/\",\"name\":\"Step-by-Step: Writing a Bond Smart Contract with Stellar's Soroban\",\"isPartOf\":{\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/how-to-use-stellar-soroban-to-write-a-bond-smart-contract\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/how-to-use-stellar-soroban-to-write-a-bond-smart-contract\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/04\/stellar-sorobar-smart-contracts.jpg\",\"datePublished\":\"2023-04-06T12:49:42+00:00\",\"dateModified\":\"2024-02-23T15:06:32+00:00\",\"author\":{\"@type\":\"person\",\"name\":\"Alessandra Carneiro\"},\"description\":\"Learn how to create a Stellar smart contract with our guide using Soroban effectively and takings advantage of its flexible features.\",\"breadcrumb\":{\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/how-to-use-stellar-soroban-to-write-a-bond-smart-contract\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cheesecakelabs.com\/blog\/how-to-use-stellar-soroban-to-write-a-bond-smart-contract\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/how-to-use-stellar-soroban-to-write-a-bond-smart-contract\/#primaryimage\",\"url\":\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/04\/stellar-sorobar-smart-contracts.jpg\",\"contentUrl\":\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/04\/stellar-sorobar-smart-contracts.jpg\",\"width\":1920,\"height\":860,\"caption\":\"stellar sky with stellar and soroban logos\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/how-to-use-stellar-soroban-to-write-a-bond-smart-contract\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cheesecakelabs.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How To Use Stellar\u2019s Soroban To Write a Bond Smart Contract\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/#website\",\"url\":\"https:\/\/cheesecakelabs.com\/blog\/\",\"name\":\"Cheesecake Labs\",\"description\":\"Nearshore outsourcing company for Web and Mobile design and engineering services, and staff augmentation for startups and enterprises..\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cheesecakelabs.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"name\":\"Alessandra Carneiro\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/04\/alessandra-carneiro.png\",\"contentUrl\":\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/04\/alessandra-carneiro.png\",\"caption\":\"Alessandra Carneiro\"},\"url\":\"https:\/\/cheesecakelabs.com\/blog\/autor\/alessandra-carneiro\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Step-by-Step: Writing a Bond Smart Contract with Stellar's Soroban","description":"Learn how to create a Stellar smart contract with our guide using Soroban effectively and takings advantage of its flexible features.","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:\/\/cheesecakelabs.com\/blog\/how-to-use-stellar-soroban-to-write-a-bond-smart-contract\/","og_locale":"en_US","og_type":"article","og_title":"Step-by-Step: Writing a Bond Smart Contract with Stellar's Soroban","og_description":"Learn how to create a Stellar smart contract with our guide using Soroban effectively and takings advantage of its flexible features.","og_url":"https:\/\/cheesecakelabs.com\/blog\/how-to-use-stellar-soroban-to-write-a-bond-smart-contract\/","og_site_name":"Cheesecake Labs","article_publisher":"https:\/\/www.facebook.com\/cheesecakelabs","article_published_time":"2023-04-06T12:49:42+00:00","article_modified_time":"2024-02-23T15:06:32+00:00","og_image":[{"width":1920,"height":860,"url":"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/04\/stellar-sorobar-smart-contracts.jpg","type":"image\/jpeg"}],"author":"Cheesecake Labs","twitter_card":"summary_large_image","twitter_creator":"@cheesecakelabs","twitter_site":"@cheesecakelabs","twitter_misc":{"Written by":null,"Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/cheesecakelabs.com\/blog\/how-to-use-stellar-soroban-to-write-a-bond-smart-contract\/#article","isPartOf":{"@id":"https:\/\/cheesecakelabs.com\/blog\/how-to-use-stellar-soroban-to-write-a-bond-smart-contract\/"},"author":{"name":"Alessandra Carneiro"},"headline":"How To Use Stellar\u2019s Soroban To Write a Bond Smart Contract","datePublished":"2023-04-06T12:49:42+00:00","dateModified":"2024-02-23T15:06:32+00:00","mainEntityOfPage":{"@id":"https:\/\/cheesecakelabs.com\/blog\/how-to-use-stellar-soroban-to-write-a-bond-smart-contract\/"},"wordCount":1545,"image":{"@id":"https:\/\/cheesecakelabs.com\/blog\/how-to-use-stellar-soroban-to-write-a-bond-smart-contract\/#primaryimage"},"thumbnailUrl":"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/04\/stellar-sorobar-smart-contracts.jpg","keywords":["blockchain","smart contract","soroban","stellar network"],"articleSection":["Engineering","Blockchain"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/cheesecakelabs.com\/blog\/how-to-use-stellar-soroban-to-write-a-bond-smart-contract\/","url":"https:\/\/cheesecakelabs.com\/blog\/how-to-use-stellar-soroban-to-write-a-bond-smart-contract\/","name":"Step-by-Step: Writing a Bond Smart Contract with Stellar's Soroban","isPartOf":{"@id":"https:\/\/cheesecakelabs.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/cheesecakelabs.com\/blog\/how-to-use-stellar-soroban-to-write-a-bond-smart-contract\/#primaryimage"},"image":{"@id":"https:\/\/cheesecakelabs.com\/blog\/how-to-use-stellar-soroban-to-write-a-bond-smart-contract\/#primaryimage"},"thumbnailUrl":"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/04\/stellar-sorobar-smart-contracts.jpg","datePublished":"2023-04-06T12:49:42+00:00","dateModified":"2024-02-23T15:06:32+00:00","author":{"@type":"person","name":"Alessandra Carneiro"},"description":"Learn how to create a Stellar smart contract with our guide using Soroban effectively and takings advantage of its flexible features.","breadcrumb":{"@id":"https:\/\/cheesecakelabs.com\/blog\/how-to-use-stellar-soroban-to-write-a-bond-smart-contract\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cheesecakelabs.com\/blog\/how-to-use-stellar-soroban-to-write-a-bond-smart-contract\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cheesecakelabs.com\/blog\/how-to-use-stellar-soroban-to-write-a-bond-smart-contract\/#primaryimage","url":"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/04\/stellar-sorobar-smart-contracts.jpg","contentUrl":"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/04\/stellar-sorobar-smart-contracts.jpg","width":1920,"height":860,"caption":"stellar sky with stellar and soroban logos"},{"@type":"BreadcrumbList","@id":"https:\/\/cheesecakelabs.com\/blog\/how-to-use-stellar-soroban-to-write-a-bond-smart-contract\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cheesecakelabs.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How To Use Stellar\u2019s Soroban To Write a Bond Smart Contract"}]},{"@type":"WebSite","@id":"https:\/\/cheesecakelabs.com\/blog\/#website","url":"https:\/\/cheesecakelabs.com\/blog\/","name":"Cheesecake Labs","description":"Nearshore outsourcing company for Web and Mobile design and engineering services, and staff augmentation for startups and enterprises..","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cheesecakelabs.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","name":"Alessandra Carneiro","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cheesecakelabs.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/04\/alessandra-carneiro.png","contentUrl":"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2023\/04\/alessandra-carneiro.png","caption":"Alessandra Carneiro"},"url":"https:\/\/cheesecakelabs.com\/blog\/autor\/alessandra-carneiro\/"}]}},"_links":{"self":[{"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/posts\/11236","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/users\/81"}],"replies":[{"embeddable":true,"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/comments?post=11236"}],"version-history":[{"count":6,"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/posts\/11236\/revisions"}],"predecessor-version":[{"id":11795,"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/posts\/11236\/revisions\/11795"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/media\/11245"}],"wp:attachment":[{"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/media?parent=11236"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/categories?post=11236"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/tags?post=11236"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}