From a7be4b46e459592ee39d21e2cf1e458833b580bb Mon Sep 17 00:00:00 2001 From: Mackenzie-OO7 <levaiagbara@gmail.com> Date: Sun, 17 Nov 2024 12:50:28 +0100 Subject: [PATCH 1/4] merge guides for extending ttl in rust and js --- .../guides/conventions/extending-wasm-ttl.mdx | 232 +++++++++++------- 1 file changed, 147 insertions(+), 85 deletions(-) diff --git a/docs/build/guides/conventions/extending-wasm-ttl.mdx b/docs/build/guides/conventions/extending-wasm-ttl.mdx index 332048cf0..b413e3e13 100644 --- a/docs/build/guides/conventions/extending-wasm-ttl.mdx +++ b/docs/build/guides/conventions/extending-wasm-ttl.mdx @@ -1,110 +1,172 @@ --- -title: Extend a deployed contract’s TTL with code -description: How to extend the TTL of a deployed contract's Wasm code using JavaScript SDK +title: Extend a deployed contract's TTL with code +description: How to extend the TTL of a deployed contract's Wasm code --- -# Extending a deployed contract’s TTL using code +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; + +# Extending a deployed contract's TTL using code When a smart contract is deployed on the Stellar network, its WebAssembly (Wasm) code has a [Time To Live (TTL)](../../../learn/encyclopedia/storage/state-archival.mdx#ttl) that determines how long it remains accessible. The TTL is the number of ledgers between the current ledger and the final ledger for which the contract data can still be accessed. If the TTL expires, the contract's code becomes archived and inaccessible. To prevent this, you need to periodically extend the TTL of the contract's Wasm code. -This guide will show you how to extend the TTL of a deployed contract's Wasm code using JavaScript. - -## Prerequisites - -- Stellar SDK: `npm install @stellar/stellar-sdk` -- A Stellar RPC endpoint (e.g., `https://soroban-testnet.stellar.org`) -- Basic knowledge of Stellar SDK - -## Process overview - -- Get the contract's footprint, -- Set a reasonable resource fee (perhaps start at 10,000 stroops as this is a costly operation), -- Set Soroban data as read-only, -- Set the desired ledger TTL to expire the contract, -- Create an operation `StellarSdk.Operation.extendFootprintTtl`, -- Note that a resource fee and base fee are both charged in this operation. - -## JavaScript code +This guide will show you how to extend the TTL of a deployed contract's Wasm code using the Javascript and Rust SDKs. -The code below uses Nodejs environment but same concept can also be applied in the browser using Freighter wallet or using any other [Stellar SDK](../../../tools/sdks/library.mdx). +## Understanding TTL in Soroban -```javascript -import * as StellarSdk from "@stellar/stellar-sdk"; +Before we demonstrate the TTL extension methods, you should note that in Soroban: -import { Server } from "@stellar/stellar-sdk/rpc"; +- Contract instances and code are stored in the instance storage +- TTL exists to prevent the blockchain from being cluttered with inactive contracts +- TTL extension can be done for both the contract instance and the contract code -async function extendContractWasmTTL(contractId, sourceKeypair) { - const server = new Server("https://soroban-testnet.stellar.org"); - - // Create a new transaction builder - const account = await server.getAccount(sourceKeypair.publicKey()); - const fee = "200100"; // Base fee plus resource fee - - // Get the contract instance - const contract = new StellarSdk.Contract(contractId); - const instance = contract.getFootprint(); - - // Set the Soroban data and create an operation to extend the contract's TTL - const sorobanData = new StellarSdk.SorobanDataBuilder() - .setResourceFee(200_000) - .setReadOnly([instance]) - .build(); - const transaction = new StellarSdk.TransactionBuilder(account, { - fee, - networkPassphrase: StellarSdk.Networks.TESTNET, // Use appropriate network - }) - .setSorobanData(sorobanData) - .addOperation( - StellarSdk.Operation.extendFootprintTtl({ - extendTo: 500_000, - }), - ) - .setTimeout(30) - .build(); - - // Sign and submit the transaction - transaction.sign(sourceKeypair); - const result = await server.sendTransaction(transaction); - - console.log( - "Transaction submitted. Result:", - JSON.stringify(result, null, 2), - ); - return result; -} +## Prerequisites -// Usage -const contractId = "CC6MWZMG2JPQEENRL7XVICAY5RNMHJ2OORMUHXKRDID6MNGXSSOJZLLF"; -const sourceKeypair = StellarSdk.Keypair.fromSecret( - "SXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", -); +- Stellar SDK: `npm install @stellar/stellar-sdk` for Javascript +- A Soroban RPC endpoint (e.g., `https://soroban-testnet.stellar.org`) +- Basic knowledge of the SDK in use + +## Methods for Extending TTL + +This guide will cover three ways to extend a contract's TTL: + +- Self-Extension: Extending the TTL from within the contract itself, in Rust. + + - Use case: When a contract needs to manage its own lifetime + - Process: Directly accessing the contract's instance storage to extend its TTL + +- External Extension: Extending the TTL from another contract (the deployer), in Rust. + + - Use case: When managing multiple contract instances or implementing administrative control + - Process: Using the deployer's authority to extend TTL for any contract it has deployed + +- Client Extension: Extending the TTL from an external client using Javascript. + - Use Case: When you need to manage contract TTLs through an external application or automated system. + - Process: - Get the contract's footprint - Set a reasonable resource fee (perhaps start at 10,000 stroops as this is a costly operation) - Set Soroban data as read-only - Set the desired ledger TTL to expire the contract - Create an operation `StellarSdk.Operation.extendFootprintTtl` :::note A resource fee and base fee are both charged in this operation. ::: + +<Tabs groupId="language" defaultValue="rust"> + <TabItem value="rust" label="Rust"> + ```rust + #![no_std] + use soroban_sdk::{contract, contractimpl, Env, symbol_short}; + + #[contract] + pub struct ExtendTTLContract; + + #[contractimpl] + impl ExtendTTLContract { + // Self-extension + pub fn extend_contract_ttl(env: Env, threshold: u32, extend_to: u32) { + env.storage().instance().extend_ttl(threshold, extend_to); + } + + // External extension + pub fn extend_other_contract_ttl(env: Env, contract_address: Address, threshold: u32, extend_to: u32) { + let deployer = env.deployer(); + deployer.extend_ttl( + contract_address, + threshold, + extend_to + ); + } + } + ``` + where: -extendContractWasmTTL(contractId, sourceKeypair) - .then(console.log) - .catch(console.error); -``` + - `env.storage().instance().extend_ttl(...)` is called to extend the TTL of the current contract instance. + - `threshold` is a check that ensures that the current TTL of the contract instance is less than the set threshold value. + - `extend_to` is the number of ledgers to be added to the current TTL. + - `contract_address` is the address of the contract instance whose TTL we want to extend. + - `env.deployer()` accesses the deployer, which has methods for managing the contract's lifecycle. + - `deployer.extend_ttl(...)` extends the TTL of the specified contract instance. -### Breaking Down the Code + </TabItem> -Let's walk through the key parts of this function: + <TabItem value="js" label="JS"> + The code below uses Nodejs environment but same concept can also be applied in the browser using Freighter wallet or using any other [Stellar SDK](../../../tools/sdks/library.mdx). -1. Setting up the Soroban data: The `SorobanDataBuilder()` is where we prep the Soroban-specific info for our transaction. + ```javascript + import * as StellarSdk from "@stellar/stellar-sdk"; -- We set a resource fee with `setResourceFee(200_000)`. This covers the extra costs for storage and execution. -- We use `setReadOnly([instance])` to tell the network which contract stuff we need to access. We're using `setReadOnly()` instead of `setReadWrite()` because we're just extending the TTL, not changing any data. + import { Server } from "@stellar/stellar-sdk/rpc"; -Why `setReadOnly()`? A few reasons: + async function extendContractWasmTTL(contractId, sourceKeypair) { + const server = new Server("https://soroban-testnet.stellar.org"); -- It's faster and uses fewer resources -- It's safer - we can't accidentally change data we're not supposed to -- The `ExtendFootprintTTLOp` operation needs it + // Create a new transaction builder + const account = await server.getAccount(sourceKeypair.publicKey()); + const fee = "200100"; // Base fee plus resource fee -2. Adding the operation: After setting up the Soroban data, we add the `extendFootprintTtl` operation to our transaction. We're telling it to extend the TTL to 500,000 ledgers with `extendTo: 500_000`. + // Get the contract instance + const contract = new StellarSdk.Contract(contractId); + const instance = contract.getFootprint(); -3. What's the point? This whole process is about keeping our contract's data alive in the ledger. It's like renewing a lease - we're telling the network "Hey, keep this stuff around longer, we're still using it!" + // Set the Soroban data and create an operation to extend the contract's TTL + const sorobanData = new StellarSdk.SorobanDataBuilder() + .setResourceFee(200_000) + .setReadOnly([instance]) + .build(); + const transaction = new StellarSdk.TransactionBuilder(account, { + fee, + networkPassphrase: StellarSdk.Networks.TESTNET, // Use appropriate network + }) + .setSorobanData(sorobanData) + .addOperation( + StellarSdk.Operation.extendFootprintTtl({ + extendTo: 500_000, + }), + ) + .setTimeout(30) + .build(); - This is super important for contracts that need to stick around for a while. Without extending the TTL, the contract's data could expire and disappear from the ledger. + // Sign and submit the transaction + transaction.sign(sourceKeypair); + const result = await server.sendTransaction(transaction); + + console.log( + "Transaction submitted. Result:", + JSON.stringify(result, null, 2), + ); + return result; + } + + // Usage + const contractId = "CC6MWZMG2JPQEENRL7XVICAY5RNMHJ2OORMUHXKRDID6MNGXSSOJZLLF"; + const sourceKeypair = StellarSdk.Keypair.fromSecret( + "SXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + ); + + extendContractWasmTTL(contractId, sourceKeypair) + .then(console.log) + .catch(console.error); + ``` + ### Breaking Down the Code + + Let's walk through the key parts of this function: + + 1. Setting up the Soroban data: The `SorobanDataBuilder()` is where we prep the Soroban-specific info for our transaction. + + - We set a resource fee with `setResourceFee(200_000)`. This covers the extra costs for storage and execution. + - We use `setReadOnly([instance])` to tell the network which contract stuff we need to access. We're using `setReadOnly()` instead of `setReadWrite()` because we're just extending the TTL, not changing any data. + + Why `setReadOnly()`? A few reasons: + + - It's faster and uses fewer resources + - It's safer - we can't accidentally change data we're not supposed to + - The `ExtendFootprintTTLOp` operation needs it + + 2. Adding the operation: After setting up the Soroban data, we add the `extendFootprintTtl` operation to our transaction. We're telling it to extend the TTL to 500,000 ledgers with `extendTo: 500_000`. + + 3. What's the point? This whole process is about keeping our contract's data alive in the ledger. It's like renewing a lease - we're telling the network "Hey, keep this stuff around longer, we're still using it!" + + This is super important for contracts that need to stick around for a while. Without extending the TTL, the contract's data could expire and disappear from the ledger. + + </TabItem> + +</Tabs> + +Learn how to test the TTL extension in this [guide](../archival/test-ttl-extension.mdx). Want to dive deeper? Check out the docs on the [Extend Footprint TTL operation](../../../learn/encyclopedia/storage/state-archival.mdx#extendfootprintttlop). From bed16f1e4dfc814d9ae8fcd922ea81c01c986509 Mon Sep 17 00:00:00 2001 From: Mackenzie-OO7 <levaiagbara@gmail.com> Date: Sun, 17 Nov 2024 12:54:27 +0100 Subject: [PATCH 2/4] fix formatting --- docs/build/guides/conventions/extending-wasm-ttl.mdx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/build/guides/conventions/extending-wasm-ttl.mdx b/docs/build/guides/conventions/extending-wasm-ttl.mdx index b413e3e13..bbfc8f441 100644 --- a/docs/build/guides/conventions/extending-wasm-ttl.mdx +++ b/docs/build/guides/conventions/extending-wasm-ttl.mdx @@ -44,7 +44,12 @@ This guide will cover three ways to extend a contract's TTL: - Client Extension: Extending the TTL from an external client using Javascript. - Use Case: When you need to manage contract TTLs through an external application or automated system. - - Process: - Get the contract's footprint - Set a reasonable resource fee (perhaps start at 10,000 stroops as this is a costly operation) - Set Soroban data as read-only - Set the desired ledger TTL to expire the contract - Create an operation `StellarSdk.Operation.extendFootprintTtl` :::note A resource fee and base fee are both charged in this operation. ::: + - Process: + - Get the contract's footprint + - Set a reasonable resource fee (perhaps start at 10,000 stroops as this is a costly operation) + - Set Soroban data as read-only + - Set the desired ledger TTL to expire the contract + - Create an operation `StellarSdk.Operation.extendFootprintTtl` :::note A resource fee and base fee are both charged in this operation. ::: <Tabs groupId="language" defaultValue="rust"> <TabItem value="rust" label="Rust"> From f12ed654b3458b83f54bea61d35db0a681ba19aa Mon Sep 17 00:00:00 2001 From: Elliot Voris <elliot@stellar.org> Date: Mon, 16 Dec 2024 14:40:12 -0600 Subject: [PATCH 3/4] markdown formatting --- .../guides/conventions/extending-wasm-ttl.mdx | 216 +++++++++--------- 1 file changed, 111 insertions(+), 105 deletions(-) diff --git a/docs/build/guides/conventions/extending-wasm-ttl.mdx b/docs/build/guides/conventions/extending-wasm-ttl.mdx index bbfc8f441..ceba2047f 100644 --- a/docs/build/guides/conventions/extending-wasm-ttl.mdx +++ b/docs/build/guides/conventions/extending-wasm-ttl.mdx @@ -49,127 +49,133 @@ This guide will cover three ways to extend a contract's TTL: - Set a reasonable resource fee (perhaps start at 10,000 stroops as this is a costly operation) - Set Soroban data as read-only - Set the desired ledger TTL to expire the contract - - Create an operation `StellarSdk.Operation.extendFootprintTtl` :::note A resource fee and base fee are both charged in this operation. ::: + - Create an operation `StellarSdk.Operation.extendFootprintTtl` + +:::note + +A resource fee and base fee are both charged in this operation. + +::: <Tabs groupId="language" defaultValue="rust"> - <TabItem value="rust" label="Rust"> - ```rust - #![no_std] - use soroban_sdk::{contract, contractimpl, Env, symbol_short}; - - #[contract] - pub struct ExtendTTLContract; - - #[contractimpl] - impl ExtendTTLContract { - // Self-extension - pub fn extend_contract_ttl(env: Env, threshold: u32, extend_to: u32) { - env.storage().instance().extend_ttl(threshold, extend_to); - } - - // External extension - pub fn extend_other_contract_ttl(env: Env, contract_address: Address, threshold: u32, extend_to: u32) { - let deployer = env.deployer(); - deployer.extend_ttl( - contract_address, - threshold, - extend_to - ); - } +<TabItem value="rust" label="Rust"> + +```rust +#![no_std] +use soroban_sdk::{contract, contractimpl, Env, symbol_short}; + +#[contract] +pub struct ExtendTTLContract; + +#[contractimpl] +impl ExtendTTLContract { + // Self-extension + pub fn extend_contract_ttl(env: Env, threshold: u32, extend_to: u32) { + env.storage().instance().extend_ttl(threshold, extend_to); } - ``` - where: - - - `env.storage().instance().extend_ttl(...)` is called to extend the TTL of the current contract instance. - - `threshold` is a check that ensures that the current TTL of the contract instance is less than the set threshold value. - - `extend_to` is the number of ledgers to be added to the current TTL. - - `contract_address` is the address of the contract instance whose TTL we want to extend. - - `env.deployer()` accesses the deployer, which has methods for managing the contract's lifecycle. - - `deployer.extend_ttl(...)` extends the TTL of the specified contract instance. - - </TabItem> - - <TabItem value="js" label="JS"> - The code below uses Nodejs environment but same concept can also be applied in the browser using Freighter wallet or using any other [Stellar SDK](../../../tools/sdks/library.mdx). - - ```javascript - import * as StellarSdk from "@stellar/stellar-sdk"; - - import { Server } from "@stellar/stellar-sdk/rpc"; - - async function extendContractWasmTTL(contractId, sourceKeypair) { - const server = new Server("https://soroban-testnet.stellar.org"); - - // Create a new transaction builder - const account = await server.getAccount(sourceKeypair.publicKey()); - const fee = "200100"; // Base fee plus resource fee - - // Get the contract instance - const contract = new StellarSdk.Contract(contractId); - const instance = contract.getFootprint(); - - // Set the Soroban data and create an operation to extend the contract's TTL - const sorobanData = new StellarSdk.SorobanDataBuilder() - .setResourceFee(200_000) - .setReadOnly([instance]) - .build(); - const transaction = new StellarSdk.TransactionBuilder(account, { - fee, - networkPassphrase: StellarSdk.Networks.TESTNET, // Use appropriate network - }) - .setSorobanData(sorobanData) - .addOperation( - StellarSdk.Operation.extendFootprintTtl({ - extendTo: 500_000, - }), - ) - .setTimeout(30) - .build(); - - // Sign and submit the transaction - transaction.sign(sourceKeypair); - const result = await server.sendTransaction(transaction); - - console.log( - "Transaction submitted. Result:", - JSON.stringify(result, null, 2), - ); - return result; + + // External extension + pub fn extend_other_contract_ttl(env: Env, contract_address: Address, threshold: u32, extend_to: u32) { + let deployer = env.deployer(); + deployer.extend_ttl( + contract_address, + threshold, + extend_to + ); } +} +``` + +- `env.storage().instance().extend_ttl(...)` is called to extend the TTL of the current contract instance. +- `threshold` is a check that ensures that the current TTL of the contract instance is less than the set threshold value. +- `extend_to` is the number of ledgers to be added to the current TTL. +- `contract_address` is the address of the contract instance whose TTL we want to extend. +- `env.deployer()` accesses the deployer, which has methods for managing the contract's lifecycle. +- `deployer.extend_ttl(...)` extends the TTL of the specified contract instance. + +</TabItem> +<TabItem value="js" label="JS"> + +The code below uses Nodejs environment but same concept can also be applied in the browser using Freighter wallet or using any other [Stellar SDK](../../../tools/sdks/library.mdx). + +```javascript +import * as StellarSdk from "@stellar/stellar-sdk"; + +import { Server } from "@stellar/stellar-sdk/rpc"; + +async function extendContractWasmTTL(contractId, sourceKeypair) { + const server = new Server("https://soroban-testnet.stellar.org"); + + // Create a new transaction builder + const account = await server.getAccount(sourceKeypair.publicKey()); + const fee = "200100"; // Base fee plus resource fee + + // Get the contract instance + const contract = new StellarSdk.Contract(contractId); + const instance = contract.getFootprint(); + + // Set the Soroban data and create an operation to extend the contract's TTL + const sorobanData = new StellarSdk.SorobanDataBuilder() + .setResourceFee(200_000) + .setReadOnly([instance]) + .build(); + const transaction = new StellarSdk.TransactionBuilder(account, { + fee, + networkPassphrase: StellarSdk.Networks.TESTNET, // Use appropriate network + }) + .setSorobanData(sorobanData) + .addOperation( + StellarSdk.Operation.extendFootprintTtl({ + extendTo: 500_000, + }), + ) + .setTimeout(30) + .build(); + + // Sign and submit the transaction + transaction.sign(sourceKeypair); + const result = await server.sendTransaction(transaction); + + console.log( + "Transaction submitted. Result:", + JSON.stringify(result, null, 2), + ); + return result; +} - // Usage - const contractId = "CC6MWZMG2JPQEENRL7XVICAY5RNMHJ2OORMUHXKRDID6MNGXSSOJZLLF"; - const sourceKeypair = StellarSdk.Keypair.fromSecret( - "SXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - ); +// Usage +const contractId = "CC6MWZMG2JPQEENRL7XVICAY5RNMHJ2OORMUHXKRDID6MNGXSSOJZLLF"; +const sourceKeypair = StellarSdk.Keypair.fromSecret( + "SXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", +); - extendContractWasmTTL(contractId, sourceKeypair) - .then(console.log) - .catch(console.error); - ``` - ### Breaking Down the Code +extendContractWasmTTL(contractId, sourceKeypair) + .then(console.log) + .catch(console.error); +``` - Let's walk through the key parts of this function: +### Breaking Down the Code - 1. Setting up the Soroban data: The `SorobanDataBuilder()` is where we prep the Soroban-specific info for our transaction. +Let's walk through the key parts of this function: - - We set a resource fee with `setResourceFee(200_000)`. This covers the extra costs for storage and execution. - - We use `setReadOnly([instance])` to tell the network which contract stuff we need to access. We're using `setReadOnly()` instead of `setReadWrite()` because we're just extending the TTL, not changing any data. +1. Setting up the Soroban data: The `SorobanDataBuilder()` is where we prep the Soroban-specific info for our transaction. - Why `setReadOnly()`? A few reasons: +- We set a resource fee with `setResourceFee(200_000)`. This covers the extra costs for storage and execution. +- We use `setReadOnly([instance])` to tell the network which contract stuff we need to access. We're using `setReadOnly()` instead of `setReadWrite()` because we're just extending the TTL, not changing any data. - - It's faster and uses fewer resources - - It's safer - we can't accidentally change data we're not supposed to - - The `ExtendFootprintTTLOp` operation needs it +Why `setReadOnly()`? A few reasons: - 2. Adding the operation: After setting up the Soroban data, we add the `extendFootprintTtl` operation to our transaction. We're telling it to extend the TTL to 500,000 ledgers with `extendTo: 500_000`. +- It's faster and uses fewer resources +- It's safer - we can't accidentally change data we're not supposed to +- The `ExtendFootprintTTLOp` operation needs it - 3. What's the point? This whole process is about keeping our contract's data alive in the ledger. It's like renewing a lease - we're telling the network "Hey, keep this stuff around longer, we're still using it!" +2. Adding the operation: After setting up the Soroban data, we add the `extendFootprintTtl` operation to our transaction. We're telling it to extend the TTL to 500,000 ledgers with `extendTo: 500_000`. - This is super important for contracts that need to stick around for a while. Without extending the TTL, the contract's data could expire and disappear from the ledger. +3. What's the point? This whole process is about keeping our contract's data alive in the ledger. It's like renewing a lease - we're telling the network "Hey, keep this stuff around longer, we're still using it!" - </TabItem> +This is super important for contracts that need to stick around for a while. Without extending the TTL, the contract's data could expire and disappear from the ledger. +</TabItem> </Tabs> Learn how to test the TTL extension in this [guide](../archival/test-ttl-extension.mdx). From e7159809595bb1486764bcda7d74064114357330 Mon Sep 17 00:00:00 2001 From: Elliot Voris <elliot@stellar.org> Date: Mon, 16 Dec 2024 14:45:40 -0600 Subject: [PATCH 4/4] more formatting; add a link --- .../guides/conventions/extending-wasm-ttl.mdx | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/docs/build/guides/conventions/extending-wasm-ttl.mdx b/docs/build/guides/conventions/extending-wasm-ttl.mdx index ceba2047f..8ae2e149a 100644 --- a/docs/build/guides/conventions/extending-wasm-ttl.mdx +++ b/docs/build/guides/conventions/extending-wasm-ttl.mdx @@ -25,31 +25,31 @@ Before we demonstrate the TTL extension methods, you should note that in Soroban ## Prerequisites - Stellar SDK: `npm install @stellar/stellar-sdk` for Javascript -- A Soroban RPC endpoint (e.g., `https://soroban-testnet.stellar.org`) +- A [Stellar RPC](../../../data/rpc/README.mdx) endpoint (e.g., `https://soroban-testnet.stellar.org`) - Basic knowledge of the SDK in use ## Methods for Extending TTL This guide will cover three ways to extend a contract's TTL: -- Self-Extension: Extending the TTL from within the contract itself, in Rust. +1. Self-Extension: Extending the TTL from within the contract itself, in Rust. - - Use case: When a contract needs to manage its own lifetime - - Process: Directly accessing the contract's instance storage to extend its TTL + - Use case: When a contract needs to manage its own lifetime + - Process: Directly accessing the contract's instance storage to extend its TTL -- External Extension: Extending the TTL from another contract (the deployer), in Rust. +2. External Extension: Extending the TTL from another contract (the deployer), in Rust. - - Use case: When managing multiple contract instances or implementing administrative control - - Process: Using the deployer's authority to extend TTL for any contract it has deployed + - Use case: When managing multiple contract instances or implementing administrative control + - Process: Using the deployer's authority to extend TTL for any contract it has deployed -- Client Extension: Extending the TTL from an external client using Javascript. - - Use Case: When you need to manage contract TTLs through an external application or automated system. - - Process: - - Get the contract's footprint - - Set a reasonable resource fee (perhaps start at 10,000 stroops as this is a costly operation) - - Set Soroban data as read-only - - Set the desired ledger TTL to expire the contract - - Create an operation `StellarSdk.Operation.extendFootprintTtl` +3. Client Extension: Extending the TTL from an external client using Javascript. + - Use Case: When you need to manage contract TTLs through an external application or automated system. + - Process: + - Get the contract's footprint + - Set a reasonable resource fee (perhaps start at 10,000 stroops as this is a costly operation) + - Set Soroban data as read-only + - Set the desired ledger TTL to expire the contract + - Create an operation `StellarSdk.Operation.extendFootprintTtl` :::note @@ -100,7 +100,6 @@ The code below uses Nodejs environment but same concept can also be applied in t ```javascript import * as StellarSdk from "@stellar/stellar-sdk"; - import { Server } from "@stellar/stellar-sdk/rpc"; async function extendContractWasmTTL(contractId, sourceKeypair) {