From fb9094d9f4edb5c0a3022620e3ff48607d38dd03 Mon Sep 17 00:00:00 2001 From: Otaiki1 Date: Thu, 22 Jan 2026 23:05:06 +0100 Subject: [PATCH 1/2] feat: implement tba contract --- .../contracts/event_manager/Cargo.toml | 16 + .../contracts/tba_account/Cargo.toml | 16 + .../contracts/tba_account/src/lib.rs | 240 ++++++++++++++ .../contracts/tba_account/src/test.rs | 126 +++++++ .../test/test_double_initialize.1.json | 141 ++++++++ ...xecute_before_initialization_panics.1.json | 76 +++++ .../test/test_getter_before_init.1.json | 76 +++++ .../test/test_getter_functions.1.json | 143 ++++++++ .../test/test_initialize.1.json | 142 ++++++++ .../test/test_initialize_twice_panics.1.json | 141 ++++++++ .../test/test_nonce_initial_value.1.json | 141 ++++++++ .../test/test_token_function.1.json | 141 ++++++++ .../contracts/tba_registry/Cargo.toml | 16 + .../contracts/ticket_factory/Cargo.toml | 16 + .../contracts/ticket_nft/Cargo.toml | 16 + soroban-contract/llms.txt | 289 ++++++++++++++++ soroban-contract/tba.txt | 312 ++++++++++++++++++ 17 files changed, 2048 insertions(+) create mode 100644 soroban-contract/contracts/tba_account/src/test.rs create mode 100644 soroban-contract/contracts/tba_account/test_snapshots/test/test_double_initialize.1.json create mode 100644 soroban-contract/contracts/tba_account/test_snapshots/test/test_execute_before_initialization_panics.1.json create mode 100644 soroban-contract/contracts/tba_account/test_snapshots/test/test_getter_before_init.1.json create mode 100644 soroban-contract/contracts/tba_account/test_snapshots/test/test_getter_functions.1.json create mode 100644 soroban-contract/contracts/tba_account/test_snapshots/test/test_initialize.1.json create mode 100644 soroban-contract/contracts/tba_account/test_snapshots/test/test_initialize_twice_panics.1.json create mode 100644 soroban-contract/contracts/tba_account/test_snapshots/test/test_nonce_initial_value.1.json create mode 100644 soroban-contract/contracts/tba_account/test_snapshots/test/test_token_function.1.json create mode 100644 soroban-contract/llms.txt create mode 100644 soroban-contract/tba.txt diff --git a/soroban-contract/contracts/event_manager/Cargo.toml b/soroban-contract/contracts/event_manager/Cargo.toml index e69de29..7862db3 100644 --- a/soroban-contract/contracts/event_manager/Cargo.toml +++ b/soroban-contract/contracts/event_manager/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "event_manager" +version = "0.0.0" +edition = "2021" +publish = false + +[lib] +crate-type = ["lib", "cdylib"] +doctest = false + +[dependencies] +soroban-sdk = { workspace = true } + +[dev-dependencies] +soroban-sdk = { workspace = true, features = ["testutils"] } + diff --git a/soroban-contract/contracts/tba_account/Cargo.toml b/soroban-contract/contracts/tba_account/Cargo.toml index e69de29..f2412a6 100644 --- a/soroban-contract/contracts/tba_account/Cargo.toml +++ b/soroban-contract/contracts/tba_account/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "tba_account" +version = "0.0.0" +edition = "2021" +publish = false + +[lib] +crate-type = ["lib", "cdylib"] +doctest = false + +[dependencies] +soroban-sdk = { workspace = true } + +[dev-dependencies] +soroban-sdk = { workspace = true, features = ["testutils"] } + diff --git a/soroban-contract/contracts/tba_account/src/lib.rs b/soroban-contract/contracts/tba_account/src/lib.rs index e69de29..1b32aab 100644 --- a/soroban-contract/contracts/tba_account/src/lib.rs +++ b/soroban-contract/contracts/tba_account/src/lib.rs @@ -0,0 +1,240 @@ +#![no_std] +use soroban_sdk::{ + contract, contractimpl, contracttype, Address, BytesN, Env, Vec, Symbol, Val, + auth::Context, +}; + +#[contract] +pub struct TbaAccount; + +#[contracttype] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum DataKey { + TokenContract, // Address of the NFT contract + TokenId, // Specific NFT token ID (u128) + ImplementationHash, // Hash used for deployment (u256) + Salt, // Deployment salt (u256) + Initialized, // Init flag + Nonce, // Transaction nonce counter +} + +// Helper functions for storage +fn get_token_contract(env: &Env) -> Address { + env.storage() + .instance() + .get(&DataKey::TokenContract) + .expect("Contract not initialized") +} + +fn set_token_contract(env: &Env, token_contract: &Address) { + env.storage().instance().set(&DataKey::TokenContract, token_contract); +} + +fn get_token_id(env: &Env) -> u128 { + env.storage() + .instance() + .get(&DataKey::TokenId) + .expect("Contract not initialized") +} + +fn set_token_id(env: &Env, token_id: &u128) { + env.storage().instance().set(&DataKey::TokenId, token_id); +} + +fn get_implementation_hash(env: &Env) -> BytesN<32> { + env.storage() + .instance() + .get(&DataKey::ImplementationHash) + .expect("Contract not initialized") +} + +fn set_implementation_hash(env: &Env, implementation_hash: &BytesN<32>) { + env.storage() + .instance() + .set(&DataKey::ImplementationHash, implementation_hash); +} + +fn get_salt(env: &Env) -> BytesN<32> { + env.storage() + .instance() + .get(&DataKey::Salt) + .expect("Contract not initialized") +} + +fn set_salt(env: &Env, salt: &BytesN<32>) { + env.storage().instance().set(&DataKey::Salt, salt); +} + +fn is_initialized(env: &Env) -> bool { + env.storage() + .instance() + .get(&DataKey::Initialized) + .unwrap_or(false) +} + +fn set_initialized(env: &Env, initialized: &bool) { + env.storage().instance().set(&DataKey::Initialized, initialized); +} + +fn get_nonce(env: &Env) -> u64 { + env.storage() + .instance() + .get(&DataKey::Nonce) + .unwrap_or(0u64) +} + +fn increment_nonce(env: &Env) -> u64 { + let current_nonce = get_nonce(env); + let new_nonce = current_nonce + 1; + env.storage().instance().set(&DataKey::Nonce, &new_nonce); + new_nonce +} + +#[contracttype] +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct TransactionExecutedEvent { + pub to: Address, + pub func: Symbol, + pub nonce: u64, +} + +// Helper function to get NFT owner by calling the NFT contract +fn get_nft_owner(env: &Env, nft_contract: &Address, token_id: u128) -> Address { + // Call the NFT contract's owner_of function + // Using invoke_contract to call the owner_of function on the NFT contract + env.invoke_contract::
( + nft_contract, + &soroban_sdk::symbol_short!("owner_of"), + soroban_sdk::vec![&env, Val::from_payload(token_id as u64)], + ) +} + +#[contractimpl] +impl TbaAccount { + /// Initialize the TBA account with NFT ownership details + /// This should be called once after deployment by the Registry + pub fn initialize( + env: Env, + token_contract: Address, + token_id: u128, + implementation_hash: BytesN<32>, + salt: BytesN<32>, + ) { + // Prevent re-initialization + if is_initialized(&env) { + panic!("Contract already initialized"); + } + + // Store all parameters + set_token_contract(&env, &token_contract); + set_token_id(&env, &token_id); + set_implementation_hash(&env, &implementation_hash); + set_salt(&env, &salt); + set_initialized(&env, &true); + } + + /// Get the NFT contract address + pub fn token_contract(env: Env) -> Address { + get_token_contract(&env) + } + + /// Get the token ID + pub fn token_id(env: Env) -> u128 { + get_token_id(&env) + } + + /// Get the current owner of the NFT (by querying the NFT contract) + pub fn owner(env: Env) -> Address { + let token_contract = get_token_contract(&env); + let token_id = get_token_id(&env); + get_nft_owner(&env, &token_contract, token_id) + } + + /// Get token details as a tuple: (chain_id, token_contract, token_id) + /// This matches the ERC-6551 pattern for compatibility + /// Note: chain_id is set to 0 as Soroban doesn't expose chain_id in the same way + pub fn token(env: Env) -> (u32, Address, u128) { + // Soroban doesn't have chain_id exposed, using 0 as placeholder + // In production, this could be set during initialization + let chain_id = 0u32; + let token_contract = get_token_contract(&env); + let token_id = get_token_id(&env); + (chain_id, token_contract, token_id) + } + + /// Get the current nonce + pub fn nonce(env: Env) -> u64 { + get_nonce(&env) + } + + /// Execute a transaction to another contract + /// Only the current NFT owner can execute transactions + /// This function increments the nonce and emits an event + pub fn execute( + env: Env, + to: Address, + func: Symbol, + args: Vec, + ) -> Vec { + // Verify contract is initialized + if !is_initialized(&env) { + panic!("Contract not initialized"); + } + + // Get the NFT owner and verify authorization + let token_contract = get_token_contract(&env); + let token_id = get_token_id(&env); + let owner = get_nft_owner(&env, &token_contract, token_id); + + // Require authorization from the NFT owner + owner.require_auth(); + + // Increment nonce + let nonce = increment_nonce(&env); + + // Emit transaction executed event + let event = TransactionExecutedEvent { + to: to.clone(), + func: func.clone(), + nonce, + }; + env.events().publish( + (Symbol::new(&env, "executed"), Symbol::new(&env, "TransactionExecuted")), + event, + ); + + // Invoke the target contract + env.invoke_contract::>(&to, &func, args) + } + + /// CustomAccountInterface implementation: Check authorization + /// Only the current NFT owner can authorize transactions + pub fn __check_auth( + env: Env, + signature_payload: BytesN<32>, + signatures: Vec>, + auth_context: Vec, + ) { + // Get the NFT contract and token ID + let token_contract = get_token_contract(&env); + let token_id = get_token_id(&env); + + // Get the current owner of the NFT + let owner = get_nft_owner(&env, &token_contract, token_id); + + // Verify that the owner has authorized this transaction + // The require_auth_for_args will check if the owner has signed + owner.require_auth_for_args( + soroban_sdk::vec![ + &env, + Val::from(signature_payload), + Val::from(signatures), + Val::from(auth_context), + ], + ); + } +} + +#[cfg(test)] +mod test; + diff --git a/soroban-contract/contracts/tba_account/src/test.rs b/soroban-contract/contracts/tba_account/src/test.rs new file mode 100644 index 0000000..15ddb0c --- /dev/null +++ b/soroban-contract/contracts/tba_account/src/test.rs @@ -0,0 +1,126 @@ +#![cfg(test)] + +use super::*; +use soroban_sdk::{ + testutils::Address as _, + vec, Address, BytesN, Env, Symbol, +}; + +// Mock NFT contract for testing +#[contract] +pub struct MockNftContract; + +#[contractimpl] +impl MockNftContract { + pub fn owner_of(_env: Env, _token_id: u128) -> Address { + // Simple mock: return a generated address + // In real tests, you'd maintain a mapping of token_id -> owner + // For now, we'll use a generated address for testing + // This is a placeholder - actual tests would need proper NFT contract integration + Address::generate(&_env) + } +} + +// Helper to create test environment +fn create_test_env() -> Env { + let env = Env::default(); + env +} + +#[test] +fn test_initialize() { + let env = create_test_env(); + let contract_id = env.register(TbaAccount, ()); + let client = TbaAccountClient::new(&env, &contract_id); + + let nft_contract = Address::generate(&env); + let token_id = 1u128; + let impl_hash = BytesN::from_array(&env, &[1u8; 32]); + let salt = BytesN::from_array(&env, &[2u8; 32]); + + // Initialize should succeed + client.initialize(&nft_contract, &token_id, &impl_hash, &salt); + + // Verify initialization + assert_eq!(client.token_contract(), nft_contract); + assert_eq!(client.token_id(), token_id); +} + +#[test] +#[should_panic(expected = "Contract already initialized")] +fn test_initialize_twice_panics() { + let env = create_test_env(); + let contract_id = env.register(TbaAccount, ()); + let client = TbaAccountClient::new(&env, &contract_id); + + let nft_contract = Address::generate(&env); + let token_id = 1u128; + let impl_hash = BytesN::from_array(&env, &[1u8; 32]); + let salt = BytesN::from_array(&env, &[2u8; 32]); + + // First initialization + client.initialize(&nft_contract, &token_id, &impl_hash, &salt); + + // Second initialization should panic + client.initialize(&nft_contract, &token_id, &impl_hash, &salt); +} + +#[test] +fn test_getter_functions() { + let env = create_test_env(); + let contract_id = env.register(TbaAccount, ()); + let client = TbaAccountClient::new(&env, &contract_id); + + let nft_contract = Address::generate(&env); + let token_id = 42u128; + let impl_hash = BytesN::from_array(&env, &[1u8; 32]); + let salt = BytesN::from_array(&env, &[2u8; 32]); + + client.initialize(&nft_contract, &token_id, &impl_hash, &salt); + + // Test getters + assert_eq!(client.token_contract(), nft_contract); + assert_eq!(client.token_id(), token_id); + + let (chain_id, contract_addr, id) = client.token(); + assert_eq!(chain_id, 0u32); // We set it to 0 + assert_eq!(contract_addr, nft_contract); + assert_eq!(id, token_id); +} + +#[test] +fn test_nonce_initial_value() { + let env = create_test_env(); + let contract_id = env.register(TbaAccount, ()); + let client = TbaAccountClient::new(&env, &contract_id); + + let nft_contract = Address::generate(&env); + let token_id = 1u128; + let impl_hash = BytesN::from_array(&env, &[1u8; 32]); + let salt = BytesN::from_array(&env, &[2u8; 32]); + + client.initialize(&nft_contract, &token_id, &impl_hash, &salt); + + // Nonce should start at 0 + assert_eq!(client.nonce(), 0u64); +} + +#[test] +#[should_panic(expected = "Contract not initialized")] +fn test_execute_before_initialization_panics() { + let env = create_test_env(); + let contract_id = env.register(TbaAccount, ()); + let client = TbaAccountClient::new(&env, &contract_id); + + let target = Address::generate(&env); + let func = Symbol::new(&env, "test_func"); + let args = vec![&env]; + + // Execute should panic if not initialized + client.execute(&target, &func, &args); +} + +// Note: Testing execute with actual authorization requires more complex setup +// with proper NFT contract integration and auth simulation. +// These tests verify the basic structure and initialization. + diff --git a/soroban-contract/contracts/tba_account/test_snapshots/test/test_double_initialize.1.json b/soroban-contract/contracts/tba_account/test_snapshots/test/test_double_initialize.1.json new file mode 100644 index 0000000..07f6ea0 --- /dev/null +++ b/soroban-contract/contracts/tba_account/test_snapshots/test/test_double_initialize.1.json @@ -0,0 +1,141 @@ +{ + "generators": { + "address": 2, + "nonce": 0 + }, + "auth": [ + [], + [], + [] + ], + "ledger": { + "protocol_version": 22, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "ImplementationHash" + } + ] + }, + "val": { + "bytes": "0000000000000000000000000000000000000000000000000000000000000000" + } + }, + { + "key": { + "vec": [ + { + "symbol": "Initialized" + } + ] + }, + "val": { + "bool": true + } + }, + { + "key": { + "vec": [ + { + "symbol": "Salt" + } + ] + }, + "val": { + "bytes": "0101010101010101010101010101010101010101010101010101010101010101" + } + }, + { + "key": { + "vec": [ + { + "symbol": "TokenContract" + } + ] + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + }, + { + "key": { + "vec": [ + { + "symbol": "TokenId" + } + ] + }, + "val": { + "u128": { + "hi": 0, + "lo": 1 + } + } + } + ] + } + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 4095 + ] + ] + ] + }, + "events": [] +} \ No newline at end of file diff --git a/soroban-contract/contracts/tba_account/test_snapshots/test/test_execute_before_initialization_panics.1.json b/soroban-contract/contracts/tba_account/test_snapshots/test/test_execute_before_initialization_panics.1.json new file mode 100644 index 0000000..5655749 --- /dev/null +++ b/soroban-contract/contracts/tba_account/test_snapshots/test/test_execute_before_initialization_panics.1.json @@ -0,0 +1,76 @@ +{ + "generators": { + "address": 2, + "nonce": 0 + }, + "auth": [ + [], + [] + ], + "ledger": { + "protocol_version": 22, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": null + } + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 4095 + ] + ] + ] + }, + "events": [] +} \ No newline at end of file diff --git a/soroban-contract/contracts/tba_account/test_snapshots/test/test_getter_before_init.1.json b/soroban-contract/contracts/tba_account/test_snapshots/test/test_getter_before_init.1.json new file mode 100644 index 0000000..a90f00a --- /dev/null +++ b/soroban-contract/contracts/tba_account/test_snapshots/test/test_getter_before_init.1.json @@ -0,0 +1,76 @@ +{ + "generators": { + "address": 1, + "nonce": 0 + }, + "auth": [ + [], + [] + ], + "ledger": { + "protocol_version": 22, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": null + } + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 4095 + ] + ] + ] + }, + "events": [] +} \ No newline at end of file diff --git a/soroban-contract/contracts/tba_account/test_snapshots/test/test_getter_functions.1.json b/soroban-contract/contracts/tba_account/test_snapshots/test/test_getter_functions.1.json new file mode 100644 index 0000000..fb73b70 --- /dev/null +++ b/soroban-contract/contracts/tba_account/test_snapshots/test/test_getter_functions.1.json @@ -0,0 +1,143 @@ +{ + "generators": { + "address": 2, + "nonce": 0 + }, + "auth": [ + [], + [], + [], + [], + [] + ], + "ledger": { + "protocol_version": 22, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "ImplementationHash" + } + ] + }, + "val": { + "bytes": "0101010101010101010101010101010101010101010101010101010101010101" + } + }, + { + "key": { + "vec": [ + { + "symbol": "Initialized" + } + ] + }, + "val": { + "bool": true + } + }, + { + "key": { + "vec": [ + { + "symbol": "Salt" + } + ] + }, + "val": { + "bytes": "0202020202020202020202020202020202020202020202020202020202020202" + } + }, + { + "key": { + "vec": [ + { + "symbol": "TokenContract" + } + ] + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + }, + { + "key": { + "vec": [ + { + "symbol": "TokenId" + } + ] + }, + "val": { + "u128": { + "hi": 0, + "lo": 42 + } + } + } + ] + } + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 4095 + ] + ] + ] + }, + "events": [] +} \ No newline at end of file diff --git a/soroban-contract/contracts/tba_account/test_snapshots/test/test_initialize.1.json b/soroban-contract/contracts/tba_account/test_snapshots/test/test_initialize.1.json new file mode 100644 index 0000000..289c76f --- /dev/null +++ b/soroban-contract/contracts/tba_account/test_snapshots/test/test_initialize.1.json @@ -0,0 +1,142 @@ +{ + "generators": { + "address": 2, + "nonce": 0 + }, + "auth": [ + [], + [], + [], + [] + ], + "ledger": { + "protocol_version": 22, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "ImplementationHash" + } + ] + }, + "val": { + "bytes": "0101010101010101010101010101010101010101010101010101010101010101" + } + }, + { + "key": { + "vec": [ + { + "symbol": "Initialized" + } + ] + }, + "val": { + "bool": true + } + }, + { + "key": { + "vec": [ + { + "symbol": "Salt" + } + ] + }, + "val": { + "bytes": "0202020202020202020202020202020202020202020202020202020202020202" + } + }, + { + "key": { + "vec": [ + { + "symbol": "TokenContract" + } + ] + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + }, + { + "key": { + "vec": [ + { + "symbol": "TokenId" + } + ] + }, + "val": { + "u128": { + "hi": 0, + "lo": 1 + } + } + } + ] + } + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 4095 + ] + ] + ] + }, + "events": [] +} \ No newline at end of file diff --git a/soroban-contract/contracts/tba_account/test_snapshots/test/test_initialize_twice_panics.1.json b/soroban-contract/contracts/tba_account/test_snapshots/test/test_initialize_twice_panics.1.json new file mode 100644 index 0000000..899a7db --- /dev/null +++ b/soroban-contract/contracts/tba_account/test_snapshots/test/test_initialize_twice_panics.1.json @@ -0,0 +1,141 @@ +{ + "generators": { + "address": 2, + "nonce": 0 + }, + "auth": [ + [], + [], + [] + ], + "ledger": { + "protocol_version": 22, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "ImplementationHash" + } + ] + }, + "val": { + "bytes": "0101010101010101010101010101010101010101010101010101010101010101" + } + }, + { + "key": { + "vec": [ + { + "symbol": "Initialized" + } + ] + }, + "val": { + "bool": true + } + }, + { + "key": { + "vec": [ + { + "symbol": "Salt" + } + ] + }, + "val": { + "bytes": "0202020202020202020202020202020202020202020202020202020202020202" + } + }, + { + "key": { + "vec": [ + { + "symbol": "TokenContract" + } + ] + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + }, + { + "key": { + "vec": [ + { + "symbol": "TokenId" + } + ] + }, + "val": { + "u128": { + "hi": 0, + "lo": 1 + } + } + } + ] + } + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 4095 + ] + ] + ] + }, + "events": [] +} \ No newline at end of file diff --git a/soroban-contract/contracts/tba_account/test_snapshots/test/test_nonce_initial_value.1.json b/soroban-contract/contracts/tba_account/test_snapshots/test/test_nonce_initial_value.1.json new file mode 100644 index 0000000..899a7db --- /dev/null +++ b/soroban-contract/contracts/tba_account/test_snapshots/test/test_nonce_initial_value.1.json @@ -0,0 +1,141 @@ +{ + "generators": { + "address": 2, + "nonce": 0 + }, + "auth": [ + [], + [], + [] + ], + "ledger": { + "protocol_version": 22, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "ImplementationHash" + } + ] + }, + "val": { + "bytes": "0101010101010101010101010101010101010101010101010101010101010101" + } + }, + { + "key": { + "vec": [ + { + "symbol": "Initialized" + } + ] + }, + "val": { + "bool": true + } + }, + { + "key": { + "vec": [ + { + "symbol": "Salt" + } + ] + }, + "val": { + "bytes": "0202020202020202020202020202020202020202020202020202020202020202" + } + }, + { + "key": { + "vec": [ + { + "symbol": "TokenContract" + } + ] + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + }, + { + "key": { + "vec": [ + { + "symbol": "TokenId" + } + ] + }, + "val": { + "u128": { + "hi": 0, + "lo": 1 + } + } + } + ] + } + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 4095 + ] + ] + ] + }, + "events": [] +} \ No newline at end of file diff --git a/soroban-contract/contracts/tba_account/test_snapshots/test/test_token_function.1.json b/soroban-contract/contracts/tba_account/test_snapshots/test/test_token_function.1.json new file mode 100644 index 0000000..5a10820 --- /dev/null +++ b/soroban-contract/contracts/tba_account/test_snapshots/test/test_token_function.1.json @@ -0,0 +1,141 @@ +{ + "generators": { + "address": 2, + "nonce": 0 + }, + "auth": [ + [], + [], + [] + ], + "ledger": { + "protocol_version": 22, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "ImplementationHash" + } + ] + }, + "val": { + "bytes": "0000000000000000000000000000000000000000000000000000000000000000" + } + }, + { + "key": { + "vec": [ + { + "symbol": "Initialized" + } + ] + }, + "val": { + "bool": true + } + }, + { + "key": { + "vec": [ + { + "symbol": "Salt" + } + ] + }, + "val": { + "bytes": "0101010101010101010101010101010101010101010101010101010101010101" + } + }, + { + "key": { + "vec": [ + { + "symbol": "TokenContract" + } + ] + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + }, + { + "key": { + "vec": [ + { + "symbol": "TokenId" + } + ] + }, + "val": { + "u128": { + "hi": 0, + "lo": 42 + } + } + } + ] + } + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 4095 + ] + ] + ] + }, + "events": [] +} \ No newline at end of file diff --git a/soroban-contract/contracts/tba_registry/Cargo.toml b/soroban-contract/contracts/tba_registry/Cargo.toml index e69de29..c29c729 100644 --- a/soroban-contract/contracts/tba_registry/Cargo.toml +++ b/soroban-contract/contracts/tba_registry/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "tba_registry" +version = "0.0.0" +edition = "2021" +publish = false + +[lib] +crate-type = ["lib", "cdylib"] +doctest = false + +[dependencies] +soroban-sdk = { workspace = true } + +[dev-dependencies] +soroban-sdk = { workspace = true, features = ["testutils"] } + diff --git a/soroban-contract/contracts/ticket_factory/Cargo.toml b/soroban-contract/contracts/ticket_factory/Cargo.toml index e69de29..caf7fa6 100644 --- a/soroban-contract/contracts/ticket_factory/Cargo.toml +++ b/soroban-contract/contracts/ticket_factory/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "ticket_factory" +version = "0.0.0" +edition = "2021" +publish = false + +[lib] +crate-type = ["lib", "cdylib"] +doctest = false + +[dependencies] +soroban-sdk = { workspace = true } + +[dev-dependencies] +soroban-sdk = { workspace = true, features = ["testutils"] } + diff --git a/soroban-contract/contracts/ticket_nft/Cargo.toml b/soroban-contract/contracts/ticket_nft/Cargo.toml index e69de29..c347c58 100644 --- a/soroban-contract/contracts/ticket_nft/Cargo.toml +++ b/soroban-contract/contracts/ticket_nft/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "ticket_nft" +version = "0.0.0" +edition = "2021" +publish = false + +[lib] +crate-type = ["lib", "cdylib"] +doctest = false + +[dependencies] +soroban-sdk = { workspace = true } + +[dev-dependencies] +soroban-sdk = { workspace = true, features = ["testutils"] } + diff --git a/soroban-contract/llms.txt b/soroban-contract/llms.txt new file mode 100644 index 0000000..b8c472b --- /dev/null +++ b/soroban-contract/llms.txt @@ -0,0 +1,289 @@ +# Stellar Developer Documentation +Stellar is a layer-1 open-source, decentralized, peer-to-peer blockchain network that provides a framework for developers to create applications, issue assets, write smart contracts, and connect to existing financial rails. Stellar is designed to enable creators, innovators, and developers to build projects on the network that can interoperate with each other. + + +[Build](https://developers.stellar.org/docs/build) + +- [Overview](https://developers.stellar.org/docs/build) + +[Build Smart Contracts](https://developers.stellar.org/docs/build/smart-contracts) +- [Introduction](https://developers.stellar.org/docs/build/smart-contracts/overview) +- [Getting Started](https://developers.stellar.org/docs/build/smart-contracts/getting-started) +- [Example Contracts](https://developers.stellar.org/docs/build/smart-contracts/example-contracts) + +[Build Applications](https://developers.stellar.org/docs/build/apps) +- [Introduction](https://developers.stellar.org/docs/build/apps/overview) +- [Application Design Considerations](https://developers.stellar.org/docs/build/apps/application-design-considerations) +- [Tutorial: Wallet SDK](https://developers.stellar.org/docs/build/apps/wallet/overview) +- [Tutorial: Payment Application, JavaScript](https://developers.stellar.org/docs/build/apps/example-application-tutorial/overview) +- [Tutorial: Payment Application, Swift](https://developers.stellar.org/docs/build/apps/swift-payment-app) +- [Tutorial: Network Ingestion Pipeline](https://developers.stellar.org/docs/build/apps/ingest-sdk/overview) +- [Tutorial: Passkey Dapp](https://developers.stellar.org/docs/build/apps/guestbook/overview) +- [Tutorial: Dapp Frontend](https://developers.stellar.org/docs/build/apps/dapp-frontend) + +[How-To Guides](https://developers.stellar.org/docs/build/guides) +- [Contract Authorization](https://developers.stellar.org/docs/build/guides/auth) +- [Contract Conventions](https://developers.stellar.org/docs/build/guides/conventions) +- [Contract Accounts](https://developers.stellar.org/docs/build/guides/contract-accounts) +- [Contract Events](https://developers.stellar.org/docs/build/guides/events) +- [Contract Storage](https://developers.stellar.org/docs/build/guides/storage) +- [Contract Testing](https://developers.stellar.org/docs/build/guides/testing) +- [Dapp Development](https://developers.stellar.org/docs/build/guides/dapps) +- [Fees & Metering](https://developers.stellar.org/docs/build/guides/fees) +- [Freighter Wallet](https://developers.stellar.org/docs/build/guides/freighter) +- [Stellar Basics](https://developers.stellar.org/docs/build/guides/basics) +- [RPC](https://developers.stellar.org/docs/build/guides/rpc) +- [State Archival](https://developers.stellar.org/docs/build/guides/archival) +- [Stellar Asset Contract Tokens](https://developers.stellar.org/docs/build/guides/tokens) +- [Transactions](https://developers.stellar.org/docs/build/guides/transactions) +- [Type Conversions](https://developers.stellar.org/docs/build/guides/conversions) + +[Security Best Practices](https://developers.stellar.org/docs/build/security-docs) + +[Learn](https://developers.stellar.org/docs/learn/fundamentals) + +[Core Concepts](https://developers.stellar.org/docs/learn/fundamentals) +- [Stellar Stack](https://developers.stellar.org/docs/learn/fundamentals/stellar-stack) +- [Lumens (XLM)](https://developers.stellar.org/docs/learn/fundamentals/lumens) +- [Stellar Consensus Protocol (SCP)](https://developers.stellar.org/docs/learn/fundamentals/stellar-consensus-protocol) +- [Data Structures](https://developers.stellar.org/docs/learn/fundamentals/stellar-data-structures) +- [Operations & Transactions](https://developers.stellar.org/docs/learn/fundamentals/transactions) +- [Fees & Metering](https://developers.stellar.org/docs/learn/fundamentals/fees-resource-limits-metering) +- [Stellar Ecosystem Proposals (SEPs)](https://developers.stellar.org/docs/learn/fundamentals/stellar-ecosystem-proposals) +- [Smart Contracts](https://developers.stellar.org/docs/learn/fundamentals/contract-development) +- [Data Format](https://developers.stellar.org/docs/learn/fundamentals/data-format) +- [Ramps (anchors)](https://developers.stellar.org/docs/learn/fundamentals/anchors) +- [SDEX](https://developers.stellar.org/docs/learn/fundamentals/liquidity-on-stellar-sdex-liquidity-pools) + +[Glossary](https://developers.stellar.org/docs/learn/glossary) +- [Migrate from Another Chain](https://developers.stellar.org/docs/learn/migrate) +- [Interactive Learning](https://developers.stellar.org/docs/learn/interactive) + +[Tokens](https://developers.stellar.org/docs/tokens) + +- [Stellar Assets & Contract Tokens](https://developers.stellar.org/docs/tokens) +- [Assets Overview](https://developers.stellar.org/docs/tokens/anatomy-of-an-asset) +- [Quickstart Guide](https://developers.stellar.org/docs/tokens/quickstart) +- [Asset Design Considerations](https://developers.stellar.org/docs/tokens/control-asset-access) +- [Stellar Asset Contract](https://developers.stellar.org/docs/tokens/stellar-asset-contract) +- [Token Interface](https://developers.stellar.org/docs/tokens/token-interface) +- [Tutorial: Issue an Asset](https://developers.stellar.org/docs/tokens/how-to-issue-an-asset) +- [Publish Asset Information](https://developers.stellar.org/docs/tokens/publishing-asset-info) + +[Data](https://developers.stellar.org/docs/data) + +- [Overview](https://developers.stellar.org/docs/data) + +[Analytics](https://developers.stellar.org/docs/data/analytics) +- [Hubble](https://developers.stellar.org/docs/data/analytics/hubble) +- [Providers](https://developers.stellar.org/docs/data/analytics/analytics-providers) + +[API](https://developers.stellar.org/docs/data/apis) +- [RPC](https://developers.stellar.org/docs/data/apis/rpc) +- [RPC Providers](https://developers.stellar.org/docs/data/apis/rpc/providers) +- [Horizon](https://developers.stellar.org/docs/data/apis/horizon) +- [Horizon Providers](https://developers.stellar.org/docs/data/apis/horizon/providers) +- [Migrate Horizon to RPC](https://developers.stellar.org/docs/data/apis/migrate-from-horizon-to-rpc) + +[Indexers](https://developers.stellar.org/docs/data/indexers) +- [Build Your Own](https://developers.stellar.org/docs/data/indexers/build-your-own) +- [Providers](https://developers.stellar.org/docs/data/indexers) + +[Oracles](https://developers.stellar.org/docs/data/oracles) +- [Providers](https://developers.stellar.org/docs/data/oracles) + +[Tools](https://developers.stellar.org/docs/tools) + +Developer Tools +- [SDKs](https://developers.stellar.org/docs/tools/sdks) +- [Stellar CLI](https://developers.stellar.org/docs/tools/cli) +- [Lab](https://developers.stellar.org/docs/tools/lab) +- [Quickstart](https://developers.stellar.org/docs/tools/quickstart) +- [OpenZeppelin Contracts](https://developers.stellar.org/docs/tools/openzeppelin-contracts) +- [Scaffold Stellar](https://developers.stellar.org/docs/tools/scaffold-stellar) +- [More Developer Tools](https://developers.stellar.org/docs/tools/developer-tools) + +Ramps +- [MoneyGram Ramps](https://developers.stellar.org/docs/tools/ramps/moneygram) + +Infra Tools +- [Cross-Chain](https://developers.stellar.org/docs/tools/infra-tools/cross-chain) + +SDF Platforms +- [Anchor Platform](https://developers.stellar.org/platforms/anchor-platform) +- [Stellar Disbursement Platform](https://developers.stellar.org/platforms/stellar-disbursement-platform) + +[Networks](https://developers.stellar.org/docs/networks) + +- [Networks Overview](https://developers.stellar.org/docs/networks) +- [Software Versions](https://developers.stellar.org/docs/networks/software-versions) +- [Resource Limits & Fees](https://developers.stellar.org/docs/networks/resource-limits-fees) + +[Validators](https://developers.stellar.org/docs/validators) + +- [Validators Introduction](https://developers.stellar.org/docs/validators) +- [Admin Guide](https://developers.stellar.org/docs/validators/admin-guide) +- [Tier 1 Organizations](https://developers.stellar.org/docs/validators/tier-1-orgs) + +[English](https://developers.stellar.org/#) + +- [English](https://developers.stellar.org/) +- [Español](https://developers.stellar.org/es/) + +[GitHub](https://github.com/stellar/stellar-docs) + +[![](https://developers.stellar.org/assets/images/stellar-101-26081c928aa1f2587e8fa50c8820e4f0.png)](https://developers.stellar.org/docs/tokens/quickstart) + +### Asset Issuers + +Issue an asset or create a custom smart contract token. + +[Learn More](https://developers.stellar.org/docs/tokens/quickstart) + +[![](https://developers.stellar.org/assets/images/contract-4360e7119b2a4ba81b3849ea53901d98.png)](https://developers.stellar.org/docs/build/smart-contracts/getting-started) + +### Smart Contract Developers + +Write smart contracts on the Stellar network. + +[Learn More](https://developers.stellar.org/docs/build/smart-contracts/getting-started) + +[![](https://developers.stellar.org/assets/images/issue-assets-89ec386030248f486d74852861375c43.png)](https://developers.stellar.org/docs/learn/fundamentals/anchors) + +### Ramps (Anchors) + +Learn about and set up an anchor. + +[Learn More](https://developers.stellar.org/docs/learn/fundamentals/anchors) + +[![](https://developers.stellar.org/assets/images/build-applications-41ff5c71635741622bf54098505815da.png)](https://developers.stellar.org/docs/build/apps/overview) + +### Applications + +Build a traditional wallet, dapp, or list Stellar assets on an exchange. + +[Learn More](https://developers.stellar.org/docs/build/apps/overview) + +[![](https://developers.stellar.org/assets/images/dev-tools-80163b11f1e5d7aee9a2d7e24c680762.png)](https://developers.stellar.org/docs/data/apis) + +### Infrastructure Providers + +Set up a Horizon or RPC service. + +[Learn More](https://developers.stellar.org/docs/data/apis) + +[![](https://developers.stellar.org/assets/images/access-data-cd89f8e864d88bc2518f0b4716946071.png)](https://developers.stellar.org/docs/data/analytics) + +### Analytics + +Use Hubble to perform analysis on Stellar network data. + +[Learn More](https://developers.stellar.org/docs/data/analytics) + + +## **Navigating the docs** [​](https://developers.stellar.org/\#navigating-the-docs "Direct link to navigating-the-docs") + +What each main section of the developer docs contains. + +### Build + +Contains tutorials and how-to guides for writing smart contracts, building applications, interacting with the network, and more. + +[Explore](https://developers.stellar.org/docs/build) + +### Learn + +Find all informational and conceptual content here. Learn about Stellar fundamentals like how accounts and transactions function, dive deeper into the functionality of each operation, discover how fees work, and more. + +[Explore](https://developers.stellar.org/docs/learn/fundamentals) + +### Tokens + +Information on how to issue assets on the Stellar network and create custom smart contract tokens. + +[Explore](https://developers.stellar.org/docs/tokens) + +### Data + +Discover various data availability options: RPC, Hubble, Horizon, Galexie, and data indexers. + +[Explore](https://developers.stellar.org/docs/data) + +### Tools + +Learn about all the available tools for building on, interacting with, or just watching the Stellar network. Also, find information on how to use the Anchor Platform or Stellar Disbursement Platform. + +[Explore](https://developers.stellar.org/docs/tools) + +### Networks + +Information about deployed networks (Mainnet, Testnet, and Futurenet), current software versions, resource limitations, and fees. + +[Explore](https://developers.stellar.org/docs/networks) + +### Validators + +Everything you'll need to know if you want to run, operate, and maintain a core validator node on the Stellar network. + +[Explore](https://developers.stellar.org/docs/validators) + +## **Developer resources** [​](https://developers.stellar.org/\#developer-resources "Direct link to developer-resources") + +Interact with other Stellar developers, keep up with ecosystem standards and protocol upgrades, and learn about upcoming events. + +### Stellar Developer Discord + +Ask questions and engage with other Stellar devs. + +[Explore](https://discord.gg/stellardev) + +### Developer Site + +Get the latest news and insights about building on Stellar. + +[Explore](https://stellar.org/developers) + +### Stellar Stack Exchange + +A question and answer site for Stellar developers; if you can’t find what you’re looking for in the docs, try searching the Stack Exchange to see if your question has been addressed. If it hasn't, feel free to ask! + +[Explore](https://stellar.stackexchange.com/) + +### Stellar Developers Google Group + +Discuss Core Advancement Proposals (CAPs) and Stellar Ecosystem Proposals (SEPs), talk about the development of Stellar Core and Horizon, and stay informed about important network upgrades. + +[Explore](https://groups.google.com/g/stellar-dev) + + +Resources + +- [Developer Blog](https://www.stellar.org/developers-blog) +- [Stellar Quest](https://quest.stellar.org/) +- [Soroban Quest](https://fastcheapandoutofcontrol.com/tutorial) +- [YouTube](https://www.youtube.com/@StellarDevelopmentFoundation) +- [Twitch](https://m.twitch.tv/stellarorg/home) + +Tools + +- [Explorer](https://stellar.expert/) +- [Lab](https://lab.stellar.org/) +- [Status](https://status.stellar.org/) +- [Dashboard](https://dashboard.stellar.org/) +- [All Tools](https://developers.stellar.org/docs/tools) + +Community + +- [Contribute to Docs](https://github.com/stellar/stellar-docs?tab=readme-ov-file#contributing) +- [Developer Discord](https://discord.gg/stellardev) +- [Developer Meetings](https://developers.stellar.org/meetings) +- [Developer Google Group](https://groups.google.com/g/stellar-dev) +- [Stack Exchange](https://stellar.stackexchange.com/) +- [Stellar Community Fund](https://communityfund.stellar.org/) + +About + +- [About SDF](https://stellar.org/foundation) +- [Careers](https://stellar.org/foundation/careers) +- [Events](https://stellar.org/events) +- [Grants & Funding](https://stellar.org/foundation/grants-and-funding) \ No newline at end of file diff --git a/soroban-contract/tba.txt b/soroban-contract/tba.txt new file mode 100644 index 0000000..f10b987 --- /dev/null +++ b/soroban-contract/tba.txt @@ -0,0 +1,312 @@ +What if the NFT you own could perform the functions of a "wallet" and represent the asset itself as well? This would enable your asset to communicate with other smart contracts and hold other digital assets inside of it. ERC-6551: Non-fungible Token Bound Accounts, a new Ethereum Improvement Proposal, may soon make such possible. For more about blockchain and smart contracts, visit our smart contract development services. + +What is ERC-6551 (Token Bound Account) +ERC-6551 introduces the concept of Token Bound Accounts (TBAs), essentially transforming NFTs into their own smart contract wallets. Each TBA has a unique address and is directly linked to a specific NFT, unlocking a range of new functionalities: + + +Asset Storage: Unlike traditional wallets where you store your assets, NFTs themselves can now hold assets. + +dApp Interaction: NFTs can directly engage with decentralized applications (dApps) including DeFi protocols and DAOs. + +Transaction History: Each NFT maintains its own transaction history, independent of the owner's wallet history. + +When ownership of the NFT changes, all the assets contained within the TBA are transferred along with it, seamlessly transferring both the NFT and its associated holdings. + + + +You may also like | Understanding ERC-404 | The Unofficial Token Standard + +Use Cases +Gaming and Virtual Worlds +In blockchain-based games and virtual worlds, ERC-6551 can enhance the player experience by allowing NFTs to hold in-game assets. + +For example: + +Character NFTs: Each character can hold items, skills, and achievements as assets within its TBA. + +Virtual Real Estate: Property NFTs can store furniture, decorations, and even other NFTs like artwork. + +Prerequisites: +A basic knowledge of ERC-721 and ERC-1155. +knowledge of smart contracts and Ethereum. +Setup of the development environment: Metamask and Remix. +Testnet Token, such as the Sepolia testnet + +We will create and implement smart contracts on one of the given EVMs using Remix IDE. Establishing a new workspace is Remix's initial step. + +We'll refer to this workspace as ERC6551. We are going to establish three smart contracts in this workspace: + +1. ERC-721: NewNFT.sol + +2. Account.sol + +3. Registry.sol + +Two interfaces are included with these contracts as well: + +1. Account.sol for IERC6551 + +2.Registry.IERC6551.sol + +Also, Check | ERC-721 Non-Fungible Token Standard Development + + +Creating an ERC-721 Smart Contract +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.20; + +import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; +import "@openzeppelin/contracts/access/Ownable.sol"; +import "@openzeppelin/contracts/utils/Counters.sol"; +contract MyToken is ERC721, Ownable { + using Counters for Counters.Counter; + Counters.Counter private _tokenIds; + constructor(address initialOwner) + ERC721("MyToken", "MTK") + Ownable(initialOwner) + {} + + function safeMint(address to, uint256 tokenId) public onlyOwner { + _safeMint(to, tokenId); + } + function _baseURI() internal pure override returns (string memory) { + return "urlLink"; + } + +} +Copy +Creating a Registry Smart Contract +You can think of the registry, also called the Singleton Registry, as a database of NFTs and the Token Bound Accounts that go along with them. A smart contract known as the registry can be implemented on any blockchain that supports the EVM. It has no owner, is unchangeable, and lacks permission. By maintaining this registry, all Token Bound Account addresses are guaranteed to use the same scheme. + + +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.20; + +import "@openzeppelin/contracts/utils/Create2.sol"; +import "./interfaces/IERC6551Registry.sol"; + +contract ERC6551Registry is IERC6551Registry { + error InitializationFailed(); + event AccountCreated( + address _account, + address implementation, + uint256 chainId, + address tokenContract, + uint256 tokenId, + uint256 salt + ); + function createAccount( + address implementation, + uint256 chainId, + address tokenContract, + uint256 tokenId, + uint256 salt, + bytes calldata initData + ) external returns (address) { + bytes memory code = _creationCode(implementation, chainId, tokenContract, tokenId, salt); + + address _account = Create2.computeAddress( + bytes32(salt), + keccak256(code) + ); + + if (_account.code.length != 0) return _account; + + _account = Create2.deploy(0, bytes32(salt), code); + + if (initData.length != 0) { + (bool success, ) = _account.call(initData); + if (!success) revert InitializationFailed(); + } + + emit AccountCreated( + _account, + implementation, + chainId, + tokenContract, + tokenId, + salt + ); + + return _account; + } + + function account( + address implementation, + uint256 chainId, + address tokenContract, + uint256 tokenId, + uint256 salt + ) external view returns (address) { + bytes32 bytecodeHash = keccak256( + _creationCode(implementation, chainId, tokenContract, tokenId, salt) + ); + + return Create2.computeAddress(bytes32(salt), bytecodeHash); + } + + function _creationCode( + address implementation_, + uint256 chainId_, + address tokenContract_, + uint256 tokenId_, + uint256 salt_ + ) internal pure returns (bytes memory) { + return + abi.encodePacked( + hex"3d60ad80600a3d3981f3363d3d373d3d3d363d73", + implementation_, + hex"5af43d82803e903d91602b57fd5bf3", + abi.encode(salt_, chainId_, tokenContract_, tokenId_) + ); + } +} + + +Copy +createAccount: +With an implementation address, this method generates the Token Bound Account for an NFT. + +account: +Based on an implementation address, token ID, chainId, NFT address, and salt, compute the Token Bound Account address for an NFT. + + +Both the functions take the following arguments: + +implementation: The address of the deployed Account Smart Contract + +chainId: The chain ID on which the account will be created + +token contract: The address of the NFT smart contract + +tokenId: The token ID for which the TBA is to be created + +salt: It is a unique value to compute the account address + +Also, Discover | A Comprehensive Guide to ERC-6551 Token Standard + +Creating an Account Smart Contract +The Account.sol contract is the last one we will ever create. The Registry contracts createAccount() and account () methods' implementation address is this smart contract's address on the chain. This smart contract's primary purposes are: + + +executeCall: This function is used to call the operations only if the signer is the actual owner of the account. + +Owner: This function is used to return the owner address of the account linked to the provided NFT. + +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.20; + +import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; +import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import "@openzeppelin/contracts/interfaces/IERC1271.sol"; +import "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol"; + +import "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol"; +import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; +import "./interfaces/IERC6551Account.sol"; + +import "./lib/MinimalReceiver.sol"; + + contract ERC6551Account is IERC165, IERC1271, IERC6551Account { + uint256 public nonce; + event TransactionExecuted(address to,uint256 value ,bytes data); + receive() external payable {} + + function executeCall( + address to, + uint256 value, + bytes calldata data + ) external payable returns (bytes memory result) { + require(msg.sender == owner(), "Not token owner"); + + ++nonce; + + emit TransactionExecuted(to, value, data); + + bool success; + (success, result) = to.call{value: value}(data); + + if (!success) { + assembly { + revert(add(result, 32), mload(result)) + } + } + } + + function token() + external + view + returns ( + uint256, + address, + uint256 + ) + { + return ERC6551AccountLib.token(); + } + + function owner() public view returns (address) { + (uint256 chainId, address tokenContract, uint256 tokenId) = this.token(); + if (chainId != block.chainid) return address(0); + + return IERC721(tokenContract).ownerOf(tokenId); + } + + function supportsInterface(bytes4 interfaceId) public pure returns (bool) { + return (interfaceId == type(IERC165).interfaceId || + interfaceId == type(IERC6551Account).interfaceId); + } + + function isValidSignature(bytes32 hash, bytes memory signature) + external + view + returns (bytes4 magicValue) + { + bool isValid = SignatureChecker.isValidSignatureNow(owner(), hash, signature); + + if (isValid) { + return IERC1271.isValidSignature.selector; + } + + return ""; + } +} +Copy +Deploying the Smart Contracts +Compiling and implementing all three contracts is the next stage. From the file explorer area, choose the smart contract you want to deploy. Navigate to the "Compile" section and press the "compile" button. The contracts can also be automatically compiled by turning on the Auto Compile option. Next, navigate to the Deployment section and choose an address from the drop-down menu. Click the Deploy button after making sure you have chosen the relevant contract to be deployed. Repeat this step for all three contracts. + +Also, Explore | ERC-1155 | An Introduction to Multi Token Standard Development + + +Mint the ERC-721 NFT +It's time to mint the NFT now that every contract has been deployed. Choose a different address from the list and copy it. Next, go to the Deployed Contracts area, pick the owner address, and open the deployed MyNFT.sol contract. For the copied address, expand the safeMint() function and mint tokenId 1. + + +Compute TBA Address for NFT +The generated NFT's address must now be calculated. To call the method, expand the account() method under the Registry smart contract and input the following arguments. + +implementation: The address of the deployed Account smart contract + +chainId: 1 + +tokenContract: The address of the deployed NFT smart contract + +tokenId: 1 + +salt: 0 + +The account address for the supplied NFT will be calculated by this function and returned as the output. + +Creating Token Bound Account + +This will create a new TBA for the provided NFT. Now to verify, you can go into the transaction details and check the decoded output. It should be the same as the computed address. + +Also, Check | ERC-4337: Ethereum's Account Abstraction Proposal + + +Testing the TBA +We are about to make a call using this recently established Token-bound Address. Choose the owner's address from the drop-down menu to place a call from the contract. Using the TBA, we will transfer 1 ETH from the owner's address to a different address. From the Value type drop-down, choose ETH, then type 1 as the value. Choose and copy a different address from the address drop-down menu. Now, under your TBA contract, expand the executeCall() method and pass the copied address as an argument's input. Keep the bytes as [ and enter the value as 1000000000000000000 (1 ETH). Click the Transact button now. Following a successful execution, you will notice that the receiver address's balance has raised by one. + +You would receive an error and the transaction would fail if you attempted to complete this transaction from an address other than the owner's address. + From fd902c31aadf471fc84212c559f3e65ed2331e5a Mon Sep 17 00:00:00 2001 From: Otaiki1 Date: Thu, 22 Jan 2026 23:08:22 +0100 Subject: [PATCH 2/2] chore: remove unnecessary files --- soroban-contract/llms.txt | 289 ----------------------------------- soroban-contract/tba.txt | 312 -------------------------------------- 2 files changed, 601 deletions(-) delete mode 100644 soroban-contract/llms.txt delete mode 100644 soroban-contract/tba.txt diff --git a/soroban-contract/llms.txt b/soroban-contract/llms.txt deleted file mode 100644 index b8c472b..0000000 --- a/soroban-contract/llms.txt +++ /dev/null @@ -1,289 +0,0 @@ -# Stellar Developer Documentation -Stellar is a layer-1 open-source, decentralized, peer-to-peer blockchain network that provides a framework for developers to create applications, issue assets, write smart contracts, and connect to existing financial rails. Stellar is designed to enable creators, innovators, and developers to build projects on the network that can interoperate with each other. - - -[Build](https://developers.stellar.org/docs/build) - -- [Overview](https://developers.stellar.org/docs/build) - -[Build Smart Contracts](https://developers.stellar.org/docs/build/smart-contracts) -- [Introduction](https://developers.stellar.org/docs/build/smart-contracts/overview) -- [Getting Started](https://developers.stellar.org/docs/build/smart-contracts/getting-started) -- [Example Contracts](https://developers.stellar.org/docs/build/smart-contracts/example-contracts) - -[Build Applications](https://developers.stellar.org/docs/build/apps) -- [Introduction](https://developers.stellar.org/docs/build/apps/overview) -- [Application Design Considerations](https://developers.stellar.org/docs/build/apps/application-design-considerations) -- [Tutorial: Wallet SDK](https://developers.stellar.org/docs/build/apps/wallet/overview) -- [Tutorial: Payment Application, JavaScript](https://developers.stellar.org/docs/build/apps/example-application-tutorial/overview) -- [Tutorial: Payment Application, Swift](https://developers.stellar.org/docs/build/apps/swift-payment-app) -- [Tutorial: Network Ingestion Pipeline](https://developers.stellar.org/docs/build/apps/ingest-sdk/overview) -- [Tutorial: Passkey Dapp](https://developers.stellar.org/docs/build/apps/guestbook/overview) -- [Tutorial: Dapp Frontend](https://developers.stellar.org/docs/build/apps/dapp-frontend) - -[How-To Guides](https://developers.stellar.org/docs/build/guides) -- [Contract Authorization](https://developers.stellar.org/docs/build/guides/auth) -- [Contract Conventions](https://developers.stellar.org/docs/build/guides/conventions) -- [Contract Accounts](https://developers.stellar.org/docs/build/guides/contract-accounts) -- [Contract Events](https://developers.stellar.org/docs/build/guides/events) -- [Contract Storage](https://developers.stellar.org/docs/build/guides/storage) -- [Contract Testing](https://developers.stellar.org/docs/build/guides/testing) -- [Dapp Development](https://developers.stellar.org/docs/build/guides/dapps) -- [Fees & Metering](https://developers.stellar.org/docs/build/guides/fees) -- [Freighter Wallet](https://developers.stellar.org/docs/build/guides/freighter) -- [Stellar Basics](https://developers.stellar.org/docs/build/guides/basics) -- [RPC](https://developers.stellar.org/docs/build/guides/rpc) -- [State Archival](https://developers.stellar.org/docs/build/guides/archival) -- [Stellar Asset Contract Tokens](https://developers.stellar.org/docs/build/guides/tokens) -- [Transactions](https://developers.stellar.org/docs/build/guides/transactions) -- [Type Conversions](https://developers.stellar.org/docs/build/guides/conversions) - -[Security Best Practices](https://developers.stellar.org/docs/build/security-docs) - -[Learn](https://developers.stellar.org/docs/learn/fundamentals) - -[Core Concepts](https://developers.stellar.org/docs/learn/fundamentals) -- [Stellar Stack](https://developers.stellar.org/docs/learn/fundamentals/stellar-stack) -- [Lumens (XLM)](https://developers.stellar.org/docs/learn/fundamentals/lumens) -- [Stellar Consensus Protocol (SCP)](https://developers.stellar.org/docs/learn/fundamentals/stellar-consensus-protocol) -- [Data Structures](https://developers.stellar.org/docs/learn/fundamentals/stellar-data-structures) -- [Operations & Transactions](https://developers.stellar.org/docs/learn/fundamentals/transactions) -- [Fees & Metering](https://developers.stellar.org/docs/learn/fundamentals/fees-resource-limits-metering) -- [Stellar Ecosystem Proposals (SEPs)](https://developers.stellar.org/docs/learn/fundamentals/stellar-ecosystem-proposals) -- [Smart Contracts](https://developers.stellar.org/docs/learn/fundamentals/contract-development) -- [Data Format](https://developers.stellar.org/docs/learn/fundamentals/data-format) -- [Ramps (anchors)](https://developers.stellar.org/docs/learn/fundamentals/anchors) -- [SDEX](https://developers.stellar.org/docs/learn/fundamentals/liquidity-on-stellar-sdex-liquidity-pools) - -[Glossary](https://developers.stellar.org/docs/learn/glossary) -- [Migrate from Another Chain](https://developers.stellar.org/docs/learn/migrate) -- [Interactive Learning](https://developers.stellar.org/docs/learn/interactive) - -[Tokens](https://developers.stellar.org/docs/tokens) - -- [Stellar Assets & Contract Tokens](https://developers.stellar.org/docs/tokens) -- [Assets Overview](https://developers.stellar.org/docs/tokens/anatomy-of-an-asset) -- [Quickstart Guide](https://developers.stellar.org/docs/tokens/quickstart) -- [Asset Design Considerations](https://developers.stellar.org/docs/tokens/control-asset-access) -- [Stellar Asset Contract](https://developers.stellar.org/docs/tokens/stellar-asset-contract) -- [Token Interface](https://developers.stellar.org/docs/tokens/token-interface) -- [Tutorial: Issue an Asset](https://developers.stellar.org/docs/tokens/how-to-issue-an-asset) -- [Publish Asset Information](https://developers.stellar.org/docs/tokens/publishing-asset-info) - -[Data](https://developers.stellar.org/docs/data) - -- [Overview](https://developers.stellar.org/docs/data) - -[Analytics](https://developers.stellar.org/docs/data/analytics) -- [Hubble](https://developers.stellar.org/docs/data/analytics/hubble) -- [Providers](https://developers.stellar.org/docs/data/analytics/analytics-providers) - -[API](https://developers.stellar.org/docs/data/apis) -- [RPC](https://developers.stellar.org/docs/data/apis/rpc) -- [RPC Providers](https://developers.stellar.org/docs/data/apis/rpc/providers) -- [Horizon](https://developers.stellar.org/docs/data/apis/horizon) -- [Horizon Providers](https://developers.stellar.org/docs/data/apis/horizon/providers) -- [Migrate Horizon to RPC](https://developers.stellar.org/docs/data/apis/migrate-from-horizon-to-rpc) - -[Indexers](https://developers.stellar.org/docs/data/indexers) -- [Build Your Own](https://developers.stellar.org/docs/data/indexers/build-your-own) -- [Providers](https://developers.stellar.org/docs/data/indexers) - -[Oracles](https://developers.stellar.org/docs/data/oracles) -- [Providers](https://developers.stellar.org/docs/data/oracles) - -[Tools](https://developers.stellar.org/docs/tools) - -Developer Tools -- [SDKs](https://developers.stellar.org/docs/tools/sdks) -- [Stellar CLI](https://developers.stellar.org/docs/tools/cli) -- [Lab](https://developers.stellar.org/docs/tools/lab) -- [Quickstart](https://developers.stellar.org/docs/tools/quickstart) -- [OpenZeppelin Contracts](https://developers.stellar.org/docs/tools/openzeppelin-contracts) -- [Scaffold Stellar](https://developers.stellar.org/docs/tools/scaffold-stellar) -- [More Developer Tools](https://developers.stellar.org/docs/tools/developer-tools) - -Ramps -- [MoneyGram Ramps](https://developers.stellar.org/docs/tools/ramps/moneygram) - -Infra Tools -- [Cross-Chain](https://developers.stellar.org/docs/tools/infra-tools/cross-chain) - -SDF Platforms -- [Anchor Platform](https://developers.stellar.org/platforms/anchor-platform) -- [Stellar Disbursement Platform](https://developers.stellar.org/platforms/stellar-disbursement-platform) - -[Networks](https://developers.stellar.org/docs/networks) - -- [Networks Overview](https://developers.stellar.org/docs/networks) -- [Software Versions](https://developers.stellar.org/docs/networks/software-versions) -- [Resource Limits & Fees](https://developers.stellar.org/docs/networks/resource-limits-fees) - -[Validators](https://developers.stellar.org/docs/validators) - -- [Validators Introduction](https://developers.stellar.org/docs/validators) -- [Admin Guide](https://developers.stellar.org/docs/validators/admin-guide) -- [Tier 1 Organizations](https://developers.stellar.org/docs/validators/tier-1-orgs) - -[English](https://developers.stellar.org/#) - -- [English](https://developers.stellar.org/) -- [Español](https://developers.stellar.org/es/) - -[GitHub](https://github.com/stellar/stellar-docs) - -[![](https://developers.stellar.org/assets/images/stellar-101-26081c928aa1f2587e8fa50c8820e4f0.png)](https://developers.stellar.org/docs/tokens/quickstart) - -### Asset Issuers - -Issue an asset or create a custom smart contract token. - -[Learn More](https://developers.stellar.org/docs/tokens/quickstart) - -[![](https://developers.stellar.org/assets/images/contract-4360e7119b2a4ba81b3849ea53901d98.png)](https://developers.stellar.org/docs/build/smart-contracts/getting-started) - -### Smart Contract Developers - -Write smart contracts on the Stellar network. - -[Learn More](https://developers.stellar.org/docs/build/smart-contracts/getting-started) - -[![](https://developers.stellar.org/assets/images/issue-assets-89ec386030248f486d74852861375c43.png)](https://developers.stellar.org/docs/learn/fundamentals/anchors) - -### Ramps (Anchors) - -Learn about and set up an anchor. - -[Learn More](https://developers.stellar.org/docs/learn/fundamentals/anchors) - -[![](https://developers.stellar.org/assets/images/build-applications-41ff5c71635741622bf54098505815da.png)](https://developers.stellar.org/docs/build/apps/overview) - -### Applications - -Build a traditional wallet, dapp, or list Stellar assets on an exchange. - -[Learn More](https://developers.stellar.org/docs/build/apps/overview) - -[![](https://developers.stellar.org/assets/images/dev-tools-80163b11f1e5d7aee9a2d7e24c680762.png)](https://developers.stellar.org/docs/data/apis) - -### Infrastructure Providers - -Set up a Horizon or RPC service. - -[Learn More](https://developers.stellar.org/docs/data/apis) - -[![](https://developers.stellar.org/assets/images/access-data-cd89f8e864d88bc2518f0b4716946071.png)](https://developers.stellar.org/docs/data/analytics) - -### Analytics - -Use Hubble to perform analysis on Stellar network data. - -[Learn More](https://developers.stellar.org/docs/data/analytics) - - -## **Navigating the docs** [​](https://developers.stellar.org/\#navigating-the-docs "Direct link to navigating-the-docs") - -What each main section of the developer docs contains. - -### Build - -Contains tutorials and how-to guides for writing smart contracts, building applications, interacting with the network, and more. - -[Explore](https://developers.stellar.org/docs/build) - -### Learn - -Find all informational and conceptual content here. Learn about Stellar fundamentals like how accounts and transactions function, dive deeper into the functionality of each operation, discover how fees work, and more. - -[Explore](https://developers.stellar.org/docs/learn/fundamentals) - -### Tokens - -Information on how to issue assets on the Stellar network and create custom smart contract tokens. - -[Explore](https://developers.stellar.org/docs/tokens) - -### Data - -Discover various data availability options: RPC, Hubble, Horizon, Galexie, and data indexers. - -[Explore](https://developers.stellar.org/docs/data) - -### Tools - -Learn about all the available tools for building on, interacting with, or just watching the Stellar network. Also, find information on how to use the Anchor Platform or Stellar Disbursement Platform. - -[Explore](https://developers.stellar.org/docs/tools) - -### Networks - -Information about deployed networks (Mainnet, Testnet, and Futurenet), current software versions, resource limitations, and fees. - -[Explore](https://developers.stellar.org/docs/networks) - -### Validators - -Everything you'll need to know if you want to run, operate, and maintain a core validator node on the Stellar network. - -[Explore](https://developers.stellar.org/docs/validators) - -## **Developer resources** [​](https://developers.stellar.org/\#developer-resources "Direct link to developer-resources") - -Interact with other Stellar developers, keep up with ecosystem standards and protocol upgrades, and learn about upcoming events. - -### Stellar Developer Discord - -Ask questions and engage with other Stellar devs. - -[Explore](https://discord.gg/stellardev) - -### Developer Site - -Get the latest news and insights about building on Stellar. - -[Explore](https://stellar.org/developers) - -### Stellar Stack Exchange - -A question and answer site for Stellar developers; if you can’t find what you’re looking for in the docs, try searching the Stack Exchange to see if your question has been addressed. If it hasn't, feel free to ask! - -[Explore](https://stellar.stackexchange.com/) - -### Stellar Developers Google Group - -Discuss Core Advancement Proposals (CAPs) and Stellar Ecosystem Proposals (SEPs), talk about the development of Stellar Core and Horizon, and stay informed about important network upgrades. - -[Explore](https://groups.google.com/g/stellar-dev) - - -Resources - -- [Developer Blog](https://www.stellar.org/developers-blog) -- [Stellar Quest](https://quest.stellar.org/) -- [Soroban Quest](https://fastcheapandoutofcontrol.com/tutorial) -- [YouTube](https://www.youtube.com/@StellarDevelopmentFoundation) -- [Twitch](https://m.twitch.tv/stellarorg/home) - -Tools - -- [Explorer](https://stellar.expert/) -- [Lab](https://lab.stellar.org/) -- [Status](https://status.stellar.org/) -- [Dashboard](https://dashboard.stellar.org/) -- [All Tools](https://developers.stellar.org/docs/tools) - -Community - -- [Contribute to Docs](https://github.com/stellar/stellar-docs?tab=readme-ov-file#contributing) -- [Developer Discord](https://discord.gg/stellardev) -- [Developer Meetings](https://developers.stellar.org/meetings) -- [Developer Google Group](https://groups.google.com/g/stellar-dev) -- [Stack Exchange](https://stellar.stackexchange.com/) -- [Stellar Community Fund](https://communityfund.stellar.org/) - -About - -- [About SDF](https://stellar.org/foundation) -- [Careers](https://stellar.org/foundation/careers) -- [Events](https://stellar.org/events) -- [Grants & Funding](https://stellar.org/foundation/grants-and-funding) \ No newline at end of file diff --git a/soroban-contract/tba.txt b/soroban-contract/tba.txt deleted file mode 100644 index f10b987..0000000 --- a/soroban-contract/tba.txt +++ /dev/null @@ -1,312 +0,0 @@ -What if the NFT you own could perform the functions of a "wallet" and represent the asset itself as well? This would enable your asset to communicate with other smart contracts and hold other digital assets inside of it. ERC-6551: Non-fungible Token Bound Accounts, a new Ethereum Improvement Proposal, may soon make such possible. For more about blockchain and smart contracts, visit our smart contract development services. - -What is ERC-6551 (Token Bound Account) -ERC-6551 introduces the concept of Token Bound Accounts (TBAs), essentially transforming NFTs into their own smart contract wallets. Each TBA has a unique address and is directly linked to a specific NFT, unlocking a range of new functionalities: - - -Asset Storage: Unlike traditional wallets where you store your assets, NFTs themselves can now hold assets. - -dApp Interaction: NFTs can directly engage with decentralized applications (dApps) including DeFi protocols and DAOs. - -Transaction History: Each NFT maintains its own transaction history, independent of the owner's wallet history. - -When ownership of the NFT changes, all the assets contained within the TBA are transferred along with it, seamlessly transferring both the NFT and its associated holdings. - - - -You may also like | Understanding ERC-404 | The Unofficial Token Standard - -Use Cases -Gaming and Virtual Worlds -In blockchain-based games and virtual worlds, ERC-6551 can enhance the player experience by allowing NFTs to hold in-game assets. - -For example: - -Character NFTs: Each character can hold items, skills, and achievements as assets within its TBA. - -Virtual Real Estate: Property NFTs can store furniture, decorations, and even other NFTs like artwork. - -Prerequisites: -A basic knowledge of ERC-721 and ERC-1155. -knowledge of smart contracts and Ethereum. -Setup of the development environment: Metamask and Remix. -Testnet Token, such as the Sepolia testnet - -We will create and implement smart contracts on one of the given EVMs using Remix IDE. Establishing a new workspace is Remix's initial step. - -We'll refer to this workspace as ERC6551. We are going to establish three smart contracts in this workspace: - -1. ERC-721: NewNFT.sol - -2. Account.sol - -3. Registry.sol - -Two interfaces are included with these contracts as well: - -1. Account.sol for IERC6551 - -2.Registry.IERC6551.sol - -Also, Check | ERC-721 Non-Fungible Token Standard Development - - -Creating an ERC-721 Smart Contract -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.20; - -import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; -import "@openzeppelin/contracts/access/Ownable.sol"; -import "@openzeppelin/contracts/utils/Counters.sol"; -contract MyToken is ERC721, Ownable { - using Counters for Counters.Counter; - Counters.Counter private _tokenIds; - constructor(address initialOwner) - ERC721("MyToken", "MTK") - Ownable(initialOwner) - {} - - function safeMint(address to, uint256 tokenId) public onlyOwner { - _safeMint(to, tokenId); - } - function _baseURI() internal pure override returns (string memory) { - return "urlLink"; - } - -} -Copy -Creating a Registry Smart Contract -You can think of the registry, also called the Singleton Registry, as a database of NFTs and the Token Bound Accounts that go along with them. A smart contract known as the registry can be implemented on any blockchain that supports the EVM. It has no owner, is unchangeable, and lacks permission. By maintaining this registry, all Token Bound Account addresses are guaranteed to use the same scheme. - - -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.20; - -import "@openzeppelin/contracts/utils/Create2.sol"; -import "./interfaces/IERC6551Registry.sol"; - -contract ERC6551Registry is IERC6551Registry { - error InitializationFailed(); - event AccountCreated( - address _account, - address implementation, - uint256 chainId, - address tokenContract, - uint256 tokenId, - uint256 salt - ); - function createAccount( - address implementation, - uint256 chainId, - address tokenContract, - uint256 tokenId, - uint256 salt, - bytes calldata initData - ) external returns (address) { - bytes memory code = _creationCode(implementation, chainId, tokenContract, tokenId, salt); - - address _account = Create2.computeAddress( - bytes32(salt), - keccak256(code) - ); - - if (_account.code.length != 0) return _account; - - _account = Create2.deploy(0, bytes32(salt), code); - - if (initData.length != 0) { - (bool success, ) = _account.call(initData); - if (!success) revert InitializationFailed(); - } - - emit AccountCreated( - _account, - implementation, - chainId, - tokenContract, - tokenId, - salt - ); - - return _account; - } - - function account( - address implementation, - uint256 chainId, - address tokenContract, - uint256 tokenId, - uint256 salt - ) external view returns (address) { - bytes32 bytecodeHash = keccak256( - _creationCode(implementation, chainId, tokenContract, tokenId, salt) - ); - - return Create2.computeAddress(bytes32(salt), bytecodeHash); - } - - function _creationCode( - address implementation_, - uint256 chainId_, - address tokenContract_, - uint256 tokenId_, - uint256 salt_ - ) internal pure returns (bytes memory) { - return - abi.encodePacked( - hex"3d60ad80600a3d3981f3363d3d373d3d3d363d73", - implementation_, - hex"5af43d82803e903d91602b57fd5bf3", - abi.encode(salt_, chainId_, tokenContract_, tokenId_) - ); - } -} - - -Copy -createAccount: -With an implementation address, this method generates the Token Bound Account for an NFT. - -account: -Based on an implementation address, token ID, chainId, NFT address, and salt, compute the Token Bound Account address for an NFT. - - -Both the functions take the following arguments: - -implementation: The address of the deployed Account Smart Contract - -chainId: The chain ID on which the account will be created - -token contract: The address of the NFT smart contract - -tokenId: The token ID for which the TBA is to be created - -salt: It is a unique value to compute the account address - -Also, Discover | A Comprehensive Guide to ERC-6551 Token Standard - -Creating an Account Smart Contract -The Account.sol contract is the last one we will ever create. The Registry contracts createAccount() and account () methods' implementation address is this smart contract's address on the chain. This smart contract's primary purposes are: - - -executeCall: This function is used to call the operations only if the signer is the actual owner of the account. - -Owner: This function is used to return the owner address of the account linked to the provided NFT. - -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.20; - -import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; -import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import "@openzeppelin/contracts/interfaces/IERC1271.sol"; -import "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol"; - -import "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol"; -import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; -import "./interfaces/IERC6551Account.sol"; - -import "./lib/MinimalReceiver.sol"; - - contract ERC6551Account is IERC165, IERC1271, IERC6551Account { - uint256 public nonce; - event TransactionExecuted(address to,uint256 value ,bytes data); - receive() external payable {} - - function executeCall( - address to, - uint256 value, - bytes calldata data - ) external payable returns (bytes memory result) { - require(msg.sender == owner(), "Not token owner"); - - ++nonce; - - emit TransactionExecuted(to, value, data); - - bool success; - (success, result) = to.call{value: value}(data); - - if (!success) { - assembly { - revert(add(result, 32), mload(result)) - } - } - } - - function token() - external - view - returns ( - uint256, - address, - uint256 - ) - { - return ERC6551AccountLib.token(); - } - - function owner() public view returns (address) { - (uint256 chainId, address tokenContract, uint256 tokenId) = this.token(); - if (chainId != block.chainid) return address(0); - - return IERC721(tokenContract).ownerOf(tokenId); - } - - function supportsInterface(bytes4 interfaceId) public pure returns (bool) { - return (interfaceId == type(IERC165).interfaceId || - interfaceId == type(IERC6551Account).interfaceId); - } - - function isValidSignature(bytes32 hash, bytes memory signature) - external - view - returns (bytes4 magicValue) - { - bool isValid = SignatureChecker.isValidSignatureNow(owner(), hash, signature); - - if (isValid) { - return IERC1271.isValidSignature.selector; - } - - return ""; - } -} -Copy -Deploying the Smart Contracts -Compiling and implementing all three contracts is the next stage. From the file explorer area, choose the smart contract you want to deploy. Navigate to the "Compile" section and press the "compile" button. The contracts can also be automatically compiled by turning on the Auto Compile option. Next, navigate to the Deployment section and choose an address from the drop-down menu. Click the Deploy button after making sure you have chosen the relevant contract to be deployed. Repeat this step for all three contracts. - -Also, Explore | ERC-1155 | An Introduction to Multi Token Standard Development - - -Mint the ERC-721 NFT -It's time to mint the NFT now that every contract has been deployed. Choose a different address from the list and copy it. Next, go to the Deployed Contracts area, pick the owner address, and open the deployed MyNFT.sol contract. For the copied address, expand the safeMint() function and mint tokenId 1. - - -Compute TBA Address for NFT -The generated NFT's address must now be calculated. To call the method, expand the account() method under the Registry smart contract and input the following arguments. - -implementation: The address of the deployed Account smart contract - -chainId: 1 - -tokenContract: The address of the deployed NFT smart contract - -tokenId: 1 - -salt: 0 - -The account address for the supplied NFT will be calculated by this function and returned as the output. - -Creating Token Bound Account - -This will create a new TBA for the provided NFT. Now to verify, you can go into the transaction details and check the decoded output. It should be the same as the computed address. - -Also, Check | ERC-4337: Ethereum's Account Abstraction Proposal - - -Testing the TBA -We are about to make a call using this recently established Token-bound Address. Choose the owner's address from the drop-down menu to place a call from the contract. Using the TBA, we will transfer 1 ETH from the owner's address to a different address. From the Value type drop-down, choose ETH, then type 1 as the value. Choose and copy a different address from the address drop-down menu. Now, under your TBA contract, expand the executeCall() method and pass the copied address as an argument's input. Keep the bytes as [ and enter the value as 1000000000000000000 (1 ETH). Click the Transact button now. Following a successful execution, you will notice that the receiver address's balance has raised by one. - -You would receive an error and the transaction would fail if you attempted to complete this transaction from an address other than the owner's address. -