### Run Demo Locally with Shell Script Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/plotter/README.md Execute this script to install necessary software and run the demo server locally. This is a convenient way to get the example up and running. ```shell ./start-server.sh ``` -------------------------------- ### Install Trunk Source: https://github.com/multiversx/mx-sdk-rs/blob/master/contracts/examples/ping-pong-egld/dapp/readme.md Install the Trunk build tool, which is a prerequisite for running the example locally. ```bash cargo install trunk ``` -------------------------------- ### Develop without NPM Dependencies Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/plotter/README.md Run the example using any web server, such as `basic-http-server`, without relying on `npm`. This method requires installing a web server and building the WASM target for the web. ```bash # Install web server (instead you can use your local nginx for example) car go install basic-http-server wasm-pack build --target web # Note "--target web" basic-http-server ``` -------------------------------- ### Install Rust Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Installs Rust using rustup for version management and sets the stable toolchain. ```bash curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh rustup update rustup default stable ``` -------------------------------- ### Install sc-meta Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/cs-test-runner/README.md Install the sc-meta tool, which is a prerequisite for using the cs-test-runner. Ensure it is available on your system's PATH. ```sh cargo install --path framework/meta --locked ``` -------------------------------- ### Install chain simulator image Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/cs-test-runner/README.md Pull the necessary Docker image for the chain simulator using the sc-meta command. This is required before starting the simulator. ```sh sc-meta cs install ``` -------------------------------- ### Require Setup Period Live Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Checks if the setup period is currently active. If the setup period has ended, it will trigger a require statement, halting execution. ```rust fn require_setup_period_live(&self) { require!(self.setup_period_status().get(), "Setup period has ended"); } ``` -------------------------------- ### Install sc-meta and Dependencies Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Installs the sc-meta tool, wasm32 target, wasm-opt, and other necessary dependencies for smart contract development. ```bash cargo install multiversx-sc-meta --locked sc-meta install all cargo install twiggy ``` -------------------------------- ### End Setup Period in PingPong Contract Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Allows the owner to end the setup period, mint all tokens, and set the activation timestamp. Requires the setup period to be live. ```rust #[only_owner] #[endpoint(endSetupPeriod)] fn end_setup_period(&self) { self.require_setup_period_live(); let token_identifier = self.token_identifier().get(); let total_mint_tokens = self.token_total_supply().get(); self.mint_all_tokens(&token_identifier, &total_mint_tokens); let activation_timestamp = self.blockchain().get_block_timestamp(); self.activation_timestamp().set(activation_timestamp); self.setup_period_status().set(false); } ``` -------------------------------- ### Install multiversx-sc-meta Tool Source: https://github.com/multiversx/mx-sdk-rs/blob/master/framework/meta/README.md Install the MultiversX smart contract meta-programming tool using Cargo. This command requires Rust 1.78 or greater. ```bash cargo install multiversx-sc-meta ``` -------------------------------- ### Require Setup Period Ended Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Ensures that the setup period has concluded. If the setup period is still active, it will trigger a require statement, preventing further execution. ```rust fn require_setup_period_ended(&self) { require!( !(self.setup_period_status().get()), "Setup period is still active" ); } ``` -------------------------------- ### Install wasm-opt Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/cs-test-runner/README.md Install wasm-opt, a tool required for contract builds. This must be available on your system's PATH. ```sh cargo install wasm-opt ``` -------------------------------- ### Storage Mapper for Setup Period Status Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Maps storage for the boolean status of the setup period, indicating whether it is active or ended. ```rust #[storage_mapper("setupPeriodStatus")] fn setup_period_status(&self) -> SingleValueMapper; ``` -------------------------------- ### Start Perform Action Event Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Emitted when an action begins its execution process. ```rust #[event("startPerformAction")] fn start_perform_action_event(&self, data: &ActionFullInfo); ``` -------------------------------- ### Crowdfunding Proxy Setup Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Defines the CrowdfundingProxy struct and its implementation for interacting with the crowdfunding smart contract. This code is auto-generated and should not be edited manually. ```rust #![allow(dead_code)] #![allow(clippy::all)] use multiversx_sc::proxy_imports::*; pub struct CrowdfundingProxy; impl TxProxyTrait for CrowdfundingProxy where Env: TxEnv, From: TxFrom, To: TxTo, Gas: TxGas, { type TxProxyMethods = CrowdfundingProxyMethods; fn proxy_methods(self, tx: Tx) -> Self::TxProxyMethods { CrowdfundingProxyMethods { wrapped_tx: tx } } } pub struct CrowdfundingProxyMethods where Env: TxEnv, From: TxFrom, To: TxTo, Gas: TxGas, { wrapped_tx: Tx, } ``` -------------------------------- ### Run cs-test-runner Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/cs-test-runner/README.md Execute the cs-test-runner from the workspace root to build contracts, start the chain simulator, run tests, and shut down the simulator. ```sh cargo run -p cs-test-runner ``` -------------------------------- ### Run Demo Locally with Batch Script (Windows) Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/plotter/README.md For Windows users without Bash, this batch script can be used to launch the demo server locally. It provides an alternative to the shell script for Windows environments. ```batch start-server.bat ``` -------------------------------- ### Create New Smart Contract Project Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Creates a new smart contract project using the sc-meta template feature, initializing an empty project structure. ```bash sc-meta new --template empty --name my-contract ``` -------------------------------- ### KittyOwnershipProxy Initialization (Deploy) Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Provides the method to deploy the KittyOwnership contract. Requires initial parameters like birth fee and optional contract addresses. ```rust impl KittyOwnershipProxyMethods where Env: TxEnv, Env::Api: VMApi, From: TxFrom, Gas: TxGas, { pub fn init< Arg0: ProxyArg>, Arg1: ProxyArg>>, Arg2: ProxyArg>>, >( self, birth_fee: Arg0, opt_gene_science_contract_address: Arg1, opt_kitty_auction_contract_address: Arg2, ) -> TxTypedDeploy { self.wrapped_tx .payment(NotPayable) .raw_deploy() .argument(&birth_fee) .argument(&opt_gene_science_contract_address) .argument(&opt_kitty_auction_contract_address) .original_result() } } ``` -------------------------------- ### Develop with NPM and WASM Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/plotter/README.md Follow these steps to set up the project using `npm` and `webpack-dev-server`. This approach enables automatic page reloads on code changes in the `www` directory. ```bash wasm-pack build cd www npm install npm start ``` -------------------------------- ### Start Lottery Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Initializes and starts a new lottery. This function can be called directly or via the `createLotteryPool` endpoint. ```APIDOC ## start ### Description Initializes and starts a new lottery with specified parameters. ### Method POST ### Endpoint `/start` ### Parameters #### Query Parameters - **lottery_name** (ManagedBuffer) - Required - The name of the lottery. - **token_identifier** (EgldOrEsdtTokenIdentifier) - Required - The identifier of the token used for ticket purchases. - **ticket_price** (BigUint) - Required - The price of a single lottery ticket. - **opt_total_tickets** (Option) - Optional - The total number of tickets available for the lottery. Defaults to 800. - **opt_deadline** (Option) - Optional - The deadline for the lottery in seconds since epoch. Defaults to 30 days from the current timestamp. - **opt_max_entries_per_user** (Option) - Optional - The maximum number of tickets a single user can purchase. Defaults to 800. - **opt_prize_distribution** (ManagedOption>) - Optional - A vector of percentages defining the prize distribution. Defaults to 100% for the main prize. - **opt_whitelist** (ManagedOption>) - Optional - A list of addresses allowed to participate in the lottery. - **opt_burn_percentage** (OptionalValue) - Optional - The percentage of ticket revenue to burn. ### Response #### Success Response (200) - None (The function performs state changes). #### Response Example None ``` -------------------------------- ### Deploying a Smart Contract with `mx-sc-meta` Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt This snippet shows how to use the `multiversx_sc_meta_lib` to compile and deploy a smart contract. It's typically used in a meta contract's `main.rs` file. ```rust #![no_std] use multiversx_sc_meta_lib::cli_main; #[multiversx_sc::derive::contract] mod fractional_nfts { #[derive(TopLevel)] pub struct FractionalNftsContract; impl FractionalNftsContract { #[init] pub fn init(&self) { // contract initialization logic } } } fn main() { multiversx_sc_meta_lib::cli_main::(); } ``` -------------------------------- ### Deploy Output Example Source: https://github.com/multiversx/mx-sdk-rs/blob/master/contracts/feature-tests/composability/forwarder-blind/dex-interactor/README.md This TOML file contains the addresses of newly deployed contracts. These addresses must be copied into `config.toml`'s `contract_addresses` field for subsequent operations. ```toml # These are the last deployed addresses. Copy them to config.toml contract_addresses to use them. contract_addresses = [ "erd1...", "erd1...", ] ``` -------------------------------- ### Create Lottery Pool Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt An alternative endpoint to initialize and start a new lottery, functionally identical to the `start` endpoint. ```APIDOC ## create_lottery_pool ### Description Creates and starts a new lottery pool with specified parameters. This is an alias for the `start` endpoint. ### Method POST ### Endpoint `/createLotteryPool` ### Parameters #### Query Parameters - **lottery_name** (ManagedBuffer) - Required - The name of the lottery. - **token_identifier** (EgldOrEsdtTokenIdentifier) - Required - The identifier of the token used for ticket purchases. - **ticket_price** (BigUint) - Required - The price of a single lottery ticket. - **opt_total_tickets** (Option) - Optional - The total number of tickets available for the lottery. Defaults to 800. - **opt_deadline** (Option) - Optional - The deadline for the lottery in seconds since epoch. Defaults to 30 days from the current timestamp. - **opt_max_entries_per_user** (Option) - Optional - The maximum number of tickets a single user can purchase. Defaults to 800. - **opt_prize_distribution** (ManagedOption>) - Optional - A vector of percentages defining the prize distribution. Defaults to 100% for the main prize. - **opt_whitelist** (ManagedOption>) - Optional - A list of addresses allowed to participate in the lottery. - **opt_burn_percentage** (OptionalValue) - Optional - The percentage of ticket revenue to burn. ### Response #### Success Response (200) - None (The function performs state changes). #### Response Example None ``` -------------------------------- ### MultisigProxy::init Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Initializes the Multisig contract with a quorum and a board of signers. ```APIDOC ## init ### Description Initializes the Multisig contract with a quorum and a board of signers. ### Method Deploy ### Parameters - **quorum** (usize) - The minimum number of signatures required to execute an action. - **board** (MultiValueEncoded) - A list of addresses that form the board of signers. ### Response - **TxTypedDeploy** - A typed transaction for deploying the contract. ``` -------------------------------- ### Get NFT Count Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Returns the total number of NFTs managed by the contract. Use this to get the current supply of NFTs. ```rust pub fn nft_count( self, ) -> TxTypedCall { self.wrapped_tx .payment(NotPayable) .raw_call("getNftCount") .original_result() } ``` -------------------------------- ### Crowdfunding Proxy Deploy Method Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Provides the `init` method for deploying the crowdfunding contract. It requires a target amount, deadline, and the token identifier for the crowdfunding campaign. ```rust #[rustfmt::skip] impl CrowdfundingProxyMethods where Env: TxEnv, Env::Api: VMApi, From: TxFrom, Gas: TxGas, { pub fn init< Arg0: ProxyArg>, Arg1: ProxyArg, Arg2: ProxyArg>, >( self, target: Arg0, deadline: Arg1, token_identifier: Arg2, ) -> TxTypedDeploy { self.wrapped_tx .payment(NotPayable) .raw_deploy() .argument(&target) .argument(&deadline) .argument(&token_identifier) .original_result() } } ``` -------------------------------- ### Get Completed Raffle ID Count Call Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt This snippet demonstrates how to make a typed call to get the count of completed raffles. ```rust pub fn completed_raffle_id_count( self, ) -> TxTypedCall { self.wrapped_tx .payment(NotPayable) .raw_call("getCompletedRaffleIdCount") .original_result() } ``` -------------------------------- ### Initialize Adder Contract Interaction Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Sets up the Interactor, registers wallets, generates blocks, and loads contract state. This is the initial setup for interacting with the Adder contract. ```rust pub async fn new(config: Config) -> Self { let mut interactor = Interactor::new(config.gateway_uri()) .await .use_chain_simulator(config.use_chain_simulator()); interactor.set_current_dir_from_workspace("contracts/examples/adder/interactor"); let adder_owner_address = interactor.register_wallet(test_wallets::heidi()).await; let wallet_address = interactor.register_wallet(test_wallets::ivan()).await; interactor.generate_blocks(30u64).await.unwrap(); AdderInteract { interactor, adder_owner_address: adder_owner_address.into(), wallet_address: wallet_address.into(), state: State::load_state(), } } ``` -------------------------------- ### DEX Interactor Configuration Example Source: https://github.com/multiversx/mx-sdk-rs/blob/master/contracts/feature-tests/composability/forwarder-blind/dex-interactor/README.md This TOML configuration file specifies chain settings, contract addresses for WEGLD and DEX pairs, and wallet PEM file paths. Ensure contract addresses are copied from `deploy.toml` to `config.toml` before use. ```toml chain_type = 'real' gateway_uri = 'https://gateway.battleofnodes.com' wegld_address = 'erd1...' # WEGLD swap contract pair_address = 'erd1...' # WEGLD/USDC DEX pair contract wegld_token_id = 'WEGLD-bd4d79' usdc_token_id = 'USDC-c76f1f' wallet_pem_paths = [ 'path/to/wallet1.pem', 'path/to/wallet2.pem', ] contract_addresses = [ 'erd1...', 'erd1...', ] ``` -------------------------------- ### Get Action Signers Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Gets the addresses of all users who have signed a specific action. Note that this list may include users who are no longer board members and whose signatures might be invalid. ```rust pub fn get_action_signers< Arg0: ProxyArg, >( self, action_id: Arg0, ) -> TxTypedCall>> { self.wrapped_tx .payment(NotPayable) .raw_call("getActionSigners") .argument(&action_id) .original_result() } ``` -------------------------------- ### Adder Contract Build Script (main.rs) Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt The main entry point for the meta-contract build process. It uses the multiversx-sc-meta-lib to generate the contract's ABI. ```rust fn main() { multiversx_sc_meta_lib::cli_main::(); } ``` -------------------------------- ### Get Pending Action Full Info Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Retrieves all pending actions with their full serialized data, including action ID, data, and signers. Use this to get a comprehensive view of outstanding actions. ```rust pub fn get_pending_action_full_info( self, ) -> TxTypedCall>> { self.wrapped_tx .payment(NotPayable) .raw_call("getPendingActionFullInfo") .original_result() } ``` -------------------------------- ### Creating a Lottery Pool Endpoint Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt This Rust code defines the `create_lottery_pool` endpoint for a lottery smart contract. It serves as an alternative way to start a new lottery, accepting similar parameters as the `start` endpoint. ```rust #[allow_multiple_var_args] #[endpoint(createLotteryPool)] fn create_lottery_pool( &self, lottery_name: ManagedBuffer, token_identifier: EgldOrEsdtTokenIdentifier, ticket_price: BigUint, opt_total_tickets: Option, opt_deadline: Option, opt_max_entries_per_user: Option, opt_prize_distribution: ManagedOption>, opt_whitelist: ManagedOption>, opt_burn_percentage: OptionalValue, ) { self.start_lottery( lottery_name, token_identifier, ticket_price, opt_total_tickets, opt_deadline, opt_max_entries_per_user, opt_prize_distribution, opt_whitelist, opt_burn_percentage, ); } ``` -------------------------------- ### Starting a Lottery Contract Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt This Rust code defines the `start` endpoint for a lottery smart contract. It allows users to initiate a new lottery with various configurable parameters such as name, token, ticket price, deadlines, and prize distribution. ```rust #[allow_multiple_var_args] #[endpoint] fn start( &self, lottery_name: ManagedBuffer, token_identifier: EgldOrEsdtTokenIdentifier, ticket_price: BigUint, opt_total_tickets: Option, opt_deadline: Option, opt_max_entries_per_user: Option, opt_prize_distribution: ManagedOption>, opt_whitelist: ManagedOption>, opt_burn_percentage: OptionalValue, ) { self.start_lottery( lottery_name, token_identifier, ticket_price, opt_total_tickets, opt_deadline, opt_max_entries_per_user, opt_prize_distribution, opt_whitelist, opt_burn_percentage, ); } ``` -------------------------------- ### SC Deploy From Source Action Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Deploys a new smart contract from source code. Returns the new address and emits a deployment event. ```Rust Action::SCDeployFromSource { amount, source, code_metadata, arguments, } => { let gas_left = self.blockchain().get_gas_left(); self.perform_deploy_from_source_event( action_id, &amount, &source, code_metadata, gas_left, arguments.as_multi(), ); let new_address = self .tx() .egld(amount) .gas(gas_left) .raw_deploy() .from_source(source) .code_metadata(code_metadata) .arguments_raw(arguments.into()) .returns(ReturnsNewManagedAddress) .sync_call(); OptionalValue::Some(new_address) } ``` -------------------------------- ### Swap WEGLD to USDC - Blind Async V1 Method Source: https://github.com/multiversx/mx-sdk-rs/blob/master/contracts/feature-tests/composability/forwarder-blind/dex-interactor/README.md Execute a swap using the blind_async_v1 method. Requires specifying the WEGLD amount to sell. ```bash cargo run -- swap1 async1 -a 1000000000000000000 ``` -------------------------------- ### Get Deadline Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Retrieves the deadline for the ping pong interaction. ```APIDOC ## getDeadline ### Description Retrieves the deadline for the ping pong interaction. ### Method GET (or equivalent for contract state retrieval) ### Endpoint /contracts/{contract_address}/deadline ### Parameters None ### Response #### Success Response (200) - **deadline** (u64) - The deadline for the ping pong interaction. ### Response Example ```json { "deadline": 1678886400 } ``` ``` -------------------------------- ### Propose SC Deploy From Source Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Proposes a smart contract deployment from source. Requires specifying the amount, source address, code metadata, and arguments. ```rust #[endpoint(proposeSCDeployFromSource)] fn propose_sc_deploy_from_source( &self, amount: BigUint, source: ManagedAddress, code_metadata: CodeMetadata, arguments: MultiValueEncoded, ) -> usize { self.propose_action(Action::SCDeployFromSource { amount, source, code_metadata, arguments: arguments.into_vec_of_buffers(), }) } ``` -------------------------------- ### Get Contract State Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Retrieves the current state of the PingPong contract. ```APIDOC ## Get Contract State ### Description Retrieves the current state of the PingPong contract. ### Method GET (implied by `.query().get_contract_state()`) ### Endpoint `/contracts/{address}/state` (implied by `.query().to(address).get_contract_state().run()`) ### Parameters #### Path Parameters * **address** (Bech32Address) - Required - The address of the PingPong contract. #### Query Parameters None ### Request Example ```rust self.interactor .query() .to(self.state.current_ping_pong_egld_address()) .typed(proxy_ping_pong_egld::PingPongProxy) .get_contract_state() .returns(ReturnsResult) .run() .await ``` ### Response #### Success Response (200) - **state** (ContractState) - The current state of the contract. The exact structure depends on the `ContractState` definition. ``` -------------------------------- ### MultisigProxy Initialization Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Initializes the MultisigProxy with a quorum and a board of addresses. This function is used for deploying the contract. ```rust pub struct MultisigProxy; impl TxProxyTrait for MultisigProxy where Env: TxEnv, From: TxFrom, To: TxTo, Gas: TxGas, { type TxProxyMethods = MultisigProxyMethods; fn proxy_methods(self, tx: Tx) -> Self::TxProxyMethods { MultisigProxyMethods { wrapped_tx: tx } } } pub struct MultisigProxyMethods where Env: TxEnv, From: TxFrom, To: TxTo, Gas: TxGas, { wrapped_tx: Tx, } #[rustfmt::skip] impl MultisigProxyMethods where Env: TxEnv, Env::Api: VMApi, From: TxFrom, Gas: TxGas, { pub fn init< Arg0: ProxyArg, Arg1: ProxyArg>>, >( self, quorum: Arg0, board: Arg1, ) -> TxTypedDeploy { self.wrapped_tx .payment(NotPayable) .raw_deploy() .argument(&quorum) .argument(&board) .original_result() } } ``` -------------------------------- ### Get Max Funds Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Retrieves the optional funding cap for the contract. ```APIDOC ## getMaxFunds ### Description Retrieves the optional funding cap for the contract. ### Method GET (or equivalent for contract state retrieval) ### Endpoint /contracts/{contract_address}/maxFunds ### Parameters None ### Response #### Success Response (200) - **max_funds** (Option) - The optional funding cap. ### Response Example ```json { "max_funds": "100000000000000000000" } ``` ``` -------------------------------- ### get_action_signer_count Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Gets the total number of users who have signed a specific action. ```APIDOC ## get_action_signer_count ### Description Returns the total count of unique signers for a specified action. ### Method `raw_call("getActionSignerCount")` ### Parameters #### Path Parameters - **action_id** (usize): The unique identifier of the action. ### Response #### Success Response - `usize`: The number of signers for the action. ``` -------------------------------- ### Propose Smart Contract Deployment from Source Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Proposes a smart contract deployment from source code. Requires specifying the amount, source address, code metadata, and any necessary arguments. ```rust pub fn propose_sc_deploy_from_source< Arg0: ProxyArg>, Arg1: ProxyArg>, Arg2: ProxyArg, Arg3: ProxyArg>>, >( self, amount: Arg0, source: Arg1, code_metadata: Arg2, arguments: Arg3, ) -> TxTypedCall { self.wrapped_tx .payment(NotPayable) .raw_call("proposeSCDeployFromSource") .argument(&amount) .argument(&source) .argument(&code_metadata) .argument(&arguments) .original_result() } ``` -------------------------------- ### Rust: Initialize RewardsDistributionProxy Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Initializes the RewardsDistributionProxy contract with a seed NFT minter address and brackets. This is a deployment-time operation. ```rust pub fn init< Arg0: ProxyArg>, Arg1: ProxyArg>, >( self, seed_nft_minter_address: Arg0, brackets: Arg1, ) -> TxTypedDeploy { self.wrapped_tx .payment(NotPayable) .raw_deploy() .argument(&seed_nft_minter_address) .argument(&brackets) .original_result() } ``` -------------------------------- ### Get Quorum Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Retrieves the minimum number of signatures required for any action. ```rust /// Minimum number of signatures needed to perform any action. pub fn quorum( self, ) -> TxTypedCall { self.wrapped_tx .payment(NotPayable) .raw_call("getQuorum") .original_result() } ``` -------------------------------- ### Get Brackets Call Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt This snippet shows how to fetch the defined brackets for raffles. ```rust pub fn brackets( self, ) -> TxTypedCall> { self.wrapped_tx .payment(NotPayable) .raw_call("getBrackets") .original_result() } ``` -------------------------------- ### Swap WEGLD to USDC - Blind Async V2 Method Source: https://github.com/multiversx/mx-sdk-rs/blob/master/contracts/feature-tests/composability/forwarder-blind/dex-interactor/README.md Execute a swap using the blind_async_v2 method. Requires specifying the WEGLD amount to sell. ```bash cargo run -- swap1 async2 -a 1000000000000000000 ``` -------------------------------- ### Get NFT Token ID Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Retrieves the token identifier for the NFTs used in the raffles. ```APIDOC ## getNftTokenId ### Description Retrieves the token identifier for the NFTs used in the raffles. ### Method Not explicitly defined, inferred as a query method. ### Endpoint Not applicable (SDK method). ### Parameters None ### Response #### Success Response - **tokenId** (TokenIdentifier) - The identifier of the NFT token. ``` -------------------------------- ### Get Last Raffle Epoch Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Returns the epoch number of the last completed raffle. ```APIDOC ## getLastRaffleEpoch ### Description Returns the epoch number of the last completed raffle. ### Method Not explicitly defined, inferred as a query method. ### Endpoint Not applicable (SDK method). ### Parameters None ### Response #### Success Response - **epoch** (u64) - The epoch number of the last raffle. ``` -------------------------------- ### Swap USDC to WEGLD - Blind Async V1 Method Source: https://github.com/multiversx/mx-sdk-rs/blob/master/contracts/feature-tests/composability/forwarder-blind/dex-interactor/README.md Execute a swap using the blind_async_v1 method. Requires specifying the USDC amount to sell. ```bash cargo run -- swap2 async1 -a 40000 ``` -------------------------------- ### CrowdfundingProxy::init Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Initializes the Crowdfunding smart contract. This method is used during the deployment of the contract to set up essential parameters. ```APIDOC ## CrowdfundingProxy::init ### Description Initializes the Crowdfunding smart contract with a target amount, deadline, and the token identifier for the crowdfunding. ### Method `init` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```rust // Example of calling init during deployment CrowdfundingProxy::init(target, deadline, token_identifier) ``` ### Response #### Success Response (200) Returns a `TxTypedDeploy` transaction for deploying the contract. #### Response Example None ``` -------------------------------- ### Get Was Claimed Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Checks if a specific reward associated with an NFT in a raffle has already been claimed. ```APIDOC ## getWasClaimed ### Description Checks if a specific reward associated with an NFT in a raffle has already been claimed. ### Method Not explicitly defined, inferred as a query method. ### Endpoint Not applicable (SDK method). ### Parameters #### Path Parameters - **raffle_id** (u64) - Required - The ID of the raffle. - **reward_token_id** (EgldOrEsdtTokenIdentifier) - Required - The identifier of the reward token. - **reward_token_nonce** (u64) - Required - The nonce of the reward token. - **nft_nonce** (u64) - Required - The nonce of the NFT. ``` -------------------------------- ### Initialize Smart Contract Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt The constructor function is called once when the contract is deployed. ```rust use multiversx_sc::imports::*; #[multiversx_sc::contract] pub trait CryptoBubbles { /// constructor function /// is called immediately after the contract is created #[init] fn init(&self) {} // ... other functions ``` -------------------------------- ### Get Was Claimed Call Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt This snippet shows how to check if a specific reward has already been claimed. ```rust pub fn was_claimed< Arg0: ProxyArg, Arg1: ProxyArg>, Arg2: ProxyArg, Arg3: ProxyArg, >( self, raffle_id: Arg0, reward_token_id: Arg1, reward_token_nonce: Arg2, nft_nonce: Arg3, ) -> TxTypedCall { self.wrapped_tx .payment(NotPayable) .raw_call("getWasClaimed") .argument(&raffle_id) .argument(&reward_token_id) .argument(&reward_token_nonce) .argument(&nft_nonce) .original_result() } ``` -------------------------------- ### Swap WEGLD to USDC - Blind Sync Method Source: https://github.com/multiversx/mx-sdk-rs/blob/master/contracts/feature-tests/composability/forwarder-blind/dex-interactor/README.md Execute a swap using the blind_sync method. Requires WEGLD amount and optionally sets a minimum USDC acceptance. ```bash cargo run -- swap1 sync -a 1000000000000000000 -m 1000 ``` -------------------------------- ### Get Ping Amount Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Retrieves the current ping amount configured in the PingPong contract. ```APIDOC ## Get Ping Amount ### Description Retrieves the current ping amount configured in the PingPong contract. ### Method GET (implied by `.query().ping_amount()`) ### Endpoint `/contracts/{address}/ping_amount` (implied by `.query().to(address).ping_amount().run()`) ### Parameters #### Path Parameters * **address** (Bech32Address) - Required - The address of the PingPong contract. #### Query Parameters None ### Request Example ```rust self.interactor .query() .to(self.state.current_ping_pong_egld_address()) .typed(proxy_ping_pong_egld::PingPongProxy) .ping_amount() .returns(ReturnsResultUnmanaged) .run() .await ``` ### Response #### Success Response (200) - **ping_amount** (RustBigUint) - The current ping amount. ``` -------------------------------- ### Load Configuration from File Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Deserializes configuration settings from a TOML file. Ensures the configuration file exists and is readable. ```Rust // Deserializes config from file pub fn load_config() -> Self { let mut file = std::fs::File::open(CONFIG_FILE).unwrap(); let mut content = String::new(); file.read_to_string(&mut content).unwrap(); toml::from_str(&content).unwrap() } ``` -------------------------------- ### Get User Addresses Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Retrieves a list of user addresses registered with the PingPong contract. ```APIDOC ## Get User Addresses ### Description Retrieves a list of user addresses registered with the PingPong contract. ### Method GET (implied by `.query().get_user_addresses()`) ### Endpoint `/contracts/{address}/users` (implied by `.query().to(address).get_user_addresses().run()`) ### Parameters #### Path Parameters * **address** (Bech32Address) - Required - The address of the PingPong contract. #### Query Parameters None ### Request Example ```rust let response = self .interactor .query() .to(self.state.current_ping_pong_egld_address()) .typed(proxy_ping_pong_egld::PingPongProxy) .get_user_addresses() .returns(ReturnsResult) .run() .await; ``` ### Response #### Success Response (200) - **users** (Vec) - A list of Bech32 addresses. #### Response Example ```json [ "erd1...", "erd1..." ] ``` ``` -------------------------------- ### Get Ping Amount Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Retrieves the amount required to perform a ping action on the contract. ```APIDOC ## getPingAmount ### Description Retrieves the amount required to perform a ping action on the contract. ### Method GET (or equivalent for contract state retrieval) ### Endpoint /contracts/{contract_address}/pingAmount ### Parameters None ### Response #### Success Response (200) - **ping_amount** (BigUint) - The amount required for a ping. ### Response Example ```json { "ping_amount": "1000000000000000000" } ``` ``` -------------------------------- ### Swap USDC to WEGLD - Blind Async V2 Method Source: https://github.com/multiversx/mx-sdk-rs/blob/master/contracts/feature-tests/composability/forwarder-blind/dex-interactor/README.md Execute a swap using the blind_async_v2 method. Requires specifying the USDC amount to sell. ```bash cargo run -- swap2 async2 -a 40000 ``` -------------------------------- ### blind_deploy Source: https://github.com/multiversx/mx-sdk-rs/blob/master/contracts/feature-tests/composability/forwarder-blind/README.md Deploys a new smart contract with the provided code and metadata. It returns the address of the newly deployed contract and emits a `blind_deploy_ok_event`. ```APIDOC ## blind_deploy ### Description Deploys a new contract with the given code and metadata. Returns the new contract's address and emits `blind_deploy_ok_event`. ### Method POST (or equivalent for smart contract deployment) ### Endpoint `blind_deploy` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **code** (Bytes) - The contract's bytecode. - **code_metadata** (String) - Metadata for the contract code. - **...args** (Variadic) - Arguments to pass to the contract's constructor. ### Request Example ```json { "code": "0x...", "code_metadata": "some_metadata", "args": ["constructor_arg1"] } ``` ### Response #### Success Response (200) - **new_contract_address** (Address) - The address of the newly deployed contract. #### Response Example ```json { "new_contract_address": "erd1..." } ``` ``` -------------------------------- ### Get Liquidity Reserves Source: https://github.com/multiversx/mx-sdk-rs/blob/master/contracts/feature-tests/composability/forwarder-blind/dex-interactor/README.md Display the current liquidity reserves in the WEGLD/USDC trading pair. ```bash cargo run -- get-liquidity ``` -------------------------------- ### Swap USDC to WEGLD - Blind Sync Method Source: https://github.com/multiversx/mx-sdk-rs/blob/master/contracts/feature-tests/composability/forwarder-blind/dex-interactor/README.md Execute a swap using the blind_sync method. Requires USDC amount and optionally sets a minimum WEGLD acceptance. ```bash cargo run -- swap2 sync -a 40000 -m 1 ``` -------------------------------- ### Get Seed NFT Minter Address Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Retrieves the address of the Seed NFT minter contract. ```APIDOC ## getSeedNftMinterAddress ### Description Retrieves the address of the Seed NFT minter contract. ### Method Not explicitly defined, inferred as a query method. ### Endpoint Not applicable (SDK method). ### Parameters None ### Response #### Success Response - **address** (ManagedAddress) - The address of the Seed NFT minter. ``` -------------------------------- ### Get User Status Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Retrieves the status of a user, indicating whether they have pinged, ponged, or are unknown. ```APIDOC ## getUserStatus ### Description Retrieves the status of a user, indicating whether they have pinged, ponged, or are unknown. ### Method GET (or equivalent for contract state retrieval) ### Endpoint /contracts/{contract_address}/userStatus/{user_id} ### Parameters #### Path Parameters - **user_id** (usize) - Required - The unique identifier of the user. ### Response #### Success Response (200) - **user_status** (UserStatus) - The status of the user (New, Registered, Withdrawn). ### Response Example ```json { "user_status": "Registered" } ``` ``` -------------------------------- ### Get Project Status Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Retrieves the current status of the crowdfunding project (FundingPeriod, Successful, or Failed). ```APIDOC ## status ### Description Retrieves the current status of the crowdfunding project (FundingPeriod, Successful, or Failed). ### Method GET ### Endpoint /status ### Parameters None ### Response #### Success Response (200) * **status** (Status) - The current status of the crowdfunding project. Possible values are: FundingPeriod, Successful, Failed. #### Response Example ```json { "status": "FundingPeriod" } ``` ``` -------------------------------- ### Request Address Change Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Allows a user to request a change of their receiving address after the setup period has ended. ```rust //To change a receiving address, the user registers a request, which is afterwards accepted or not by the owner #[endpoint(requestAddressChange)] fn request_address_change(&self, new_address: ManagedAddress) { self.require_setup_period_ended(); let user_address = self.blockchain().get_caller(); self.address_change_request(&user_address).set(&new_address); } ``` -------------------------------- ### MultisigProxy::propose_sc_deploy_from_source Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Proposes a smart contract deployment action from a source address. This method is intended for internal use by the contract's logic. ```APIDOC ## propose_sc_deploy_from_source ### Description Proposes a smart contract deployment action from a source address. This method is intended for internal use by the contract's logic. ### Method Internal contract logic ### Parameters - **amount** (BigUint) - The amount of EGLD to be sent with the deployment. - **source** (ManagedAddress) - The address of the source code. - **code_metadata** (CodeMetadata) - Metadata for the smart contract code. - **arguments** (MultiValueEncoded) - Arguments for the smart contract constructor. ### Response - **usize** - An identifier for the proposed action. ``` -------------------------------- ### Build Smart Contract Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Builds the smart contract, generating the WASM bytecode and contract metadata. ```bash sc-meta all build ``` -------------------------------- ### Get Marketplaces Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Retrieves a list of marketplace addresses associated with the contract. Call this to see where NFTs are listed. ```rust pub fn marketplaces( self, ) -> TxTypedCall>> { self.wrapped_tx .payment(NotPayable) .raw_call("getMarketplaces") .original_result() } ``` -------------------------------- ### Get NFT Reward Percent Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Retrieves the reward percentage for a specific NFT within a given raffle. ```APIDOC ## getNftRewardPercent ### Description Retrieves the reward percentage for a specific NFT within a given raffle. ### Method Not explicitly defined, inferred as a query method. ### Endpoint Not applicable (SDK method). ### Parameters #### Path Parameters - **raffle_id** (u64) - Required - The ID of the raffle. - **nft_nonce** (u64) - Required - The nonce of the NFT. ``` -------------------------------- ### Configuring Rust Compiler Version for Builds Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/releases-explained/explained-v0.63.0.md Demonstrates how to configure the Rust compiler version for smart contract builds using the sc-config.toml file to ensure reproducible builds. ```toml [tool.rust- போ] profile = "default" [dependencies] multiversx_sc = { version = "0.63.0", workspace = true, # Use "path = "../.."" if you want to use a local version of the SDK # path = "../.." } [dev-dependencies] multiversx_sc_scenario = { version = "0.63.0", workspace = true, # Use "path = "../.."" if you want to use a local version of the SDK # path = "../.." } [build-dependencies] multiversx_sc_codec = { version = "0.63.0", workspace = true, # Use "path = "../.."" if you want to use a local version of the SDK # path = "../.." } [package] name = "my-contract" version = "0.1.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib] # See https://docs.multiversx.com/developers/build/smart-contracts/rust/contract-build/ # for more details on how to configure your contract build. # # The default build configuration is for the WASM target. # If you want to build for native, uncomment the following lines: # # [lib.crate-type] # name = "lib" # crate-type = ["rlib"] ``` -------------------------------- ### Get Raffle ID Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Retrieves the current raffle ID. This method is part of the PingPong contract functionality. ```APIDOC ## getRaffleId ### Description Retrieves the current raffle ID. ### Method Not explicitly defined, inferred as a query method. ### Endpoint Not applicable (SDK method). ### Parameters None ### Response #### Success Response - **raffleId** (u64) - The current raffle ID. ``` -------------------------------- ### Deploy NFT Contract Source: https://github.com/multiversx/mx-sdk-rs/blob/master/contracts/feature-tests/erc-style-contracts/erc721/documentation.md Initializes the NFT smart contract by creating a specified number of tokens. The deployer account becomes the owner of these initial tokens. ```rust fn init(initial_minted: u64) ``` -------------------------------- ### Get Gateway URI Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Returns the configured gateway URI for network communication. This is a simple getter method. ```Rust // Returns the gateway URI pub fn gateway_uri(&self) -> &str { &self.gateway_uri } ``` -------------------------------- ### init Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Initializes the Digital Cash contract with a specified fee and token identifier. This is a deployment-related method. ```APIDOC ## init ### Description Initializes the Digital Cash contract with a specified fee and token identifier. This is a deployment-related method. ### Method DEPLOY ### Endpoint N/A (Contract Deployment) ### Parameters #### Arguments - **fee** (ProxyArg>) - Required - The deployment fee. - **token** (ProxyArg>) - Required - The token identifier for the digital cash. ### Response #### Success Response - TxTypedDeploy ``` -------------------------------- ### Get User Addresses View Source: https://github.com/multiversx/mx-sdk-rs/blob/master/tools/git-scraper/contracts_dump.txt Retrieves a list of all user addresses that have pinged the contract, in the order they pinged. ```rust /// Lists the addresses of all users that have `ping`-ed, /// in the order they have `ping`-ed #[view(getUserAddresses)] fn get_user_addresses(&self) -> MultiValueEncoded { self.user_mapper().get_all_addresses().into() } ```