Run smart contract function

From UBot Studio
(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
'''$defi contract run''' is a function that runs a specified function on a smart contract.
+
'''$run contract function''' is a function that runs a specific function on a smart contract. This command is especially useful for enterprise users who are actively managing and interacting with various smart contracts.
 
+
Designed for enterprise users, this function is particularly useful for interacting with DeFi protocols on Avalanche and Binance Smart Chain.
+
 
+
== User Level ==
+
 
+
This function is exclusively available for enterprise users.
+
  
 
== Parameters ==
 
== Parameters ==
  
'''Chain:''' The blockchain where the smart contract is located. The options are "Avalanche" or "BinanceSmartChain".  
+
'''Chain:''' The blockchain network chain on which the smart contract resides. The chains that can be selected from the dropdown menu include Avalanche and Binance Smart Chain.
  
'''Contract Address:''' The address of the smart contract.
+
'''Contract Address:''' The address of the smart contract on which the function will be executed.
  
'''Function Name:''' The specific function that you want to run on the smart contract.
+
'''Function Name:''' The specific function that is to be executed on the smart contract.
  
'''Parameters:''' Additional parameters to be included when running the function on the smart contract.
+
'''Parameters:''' The parameters that are to be passed to the smart contract function. These have to be provided as a single string value, separated by commas.
  
== Return Value ==  
+
== Return Value ==
  
This function returns a string value that represents the output of the function that's run on the smart contract.
+
The function returns a string that represents the result of the executed smart contract function.
  
 
== Example ==
 
== Example ==
  
 
<pre>
 
<pre>
define areacode
+
ui console view
ui text msg("Function Output: {$defi contract run("BinanceSmartChain", "0x...", "swapExactETHForTokens", "['500', '0x...', '0x...', '1600396754']")}")
+
config defi wallet("your private key here")
 +
log("Smart Contract Function Result: {$run contract function("BinanceSmartChain","0xBCfCcbde45cE874adCB698cC183deBcF17952812","getReserves","")}")
 
</pre>
 
</pre>
  
In this example, the function "swapExactETHForTokens" is run on a smart contract located on the Binance Smart Chain. The smart contract address, function name, and parameters have been anonymized for security reasons. Replace these with your actual details.
+
Do remember to replace "your private key here" with your actual private key. Always handle private keys securely as they are highly sensitive information.
 +
 
 +
The output of this script will display the result returned by the executed function (in this case "getReserves") on the specified smart contract (at address "0xBCfCcbde45cE874adCB698cC183deBcF17952812" on the "BinanceSmartChain"). The output might look something like:
 +
 
 +
<blockquote>
 +
Smart Contract Function Result: 0x4a81748738792a0a8c21c0ff6f5f7c8cb6e79e30
 +
</blockquote>

Revision as of 18:57, 4 July 2023

$run contract function is a function that runs a specific function on a smart contract. This command is especially useful for enterprise users who are actively managing and interacting with various smart contracts.

Parameters

Chain: The blockchain network chain on which the smart contract resides. The chains that can be selected from the dropdown menu include Avalanche and Binance Smart Chain.

Contract Address: The address of the smart contract on which the function will be executed.

Function Name: The specific function that is to be executed on the smart contract.

Parameters: The parameters that are to be passed to the smart contract function. These have to be provided as a single string value, separated by commas.

Return Value

The function returns a string that represents the result of the executed smart contract function.

Example

ui console view
config defi wallet("your private key here")
log("Smart Contract Function Result: {$run contract function("BinanceSmartChain","0xBCfCcbde45cE874adCB698cC183deBcF17952812","getReserves","")}")

Do remember to replace "your private key here" with your actual private key. Always handle private keys securely as they are highly sensitive information.

The output of this script will display the result returned by the executed function (in this case "getReserves") on the specified smart contract (at address "0xBCfCcbde45cE874adCB698cC183deBcF17952812" on the "BinanceSmartChain"). The output might look something like:

Smart Contract Function Result: 0x4a81748738792a0a8c21c0ff6f5f7c8cb6e79e30
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox