Run smart contract function

From UBot Studio
(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
'''$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.
+
'''$run contract function''' is a function that runs a specified function on a smart contract residing on a specific blockchain.
 +
 
 +
This function interacts with smart contracts and can execute functionality like transferring tokens or calling view functions.
  
 
== Parameters ==
 
== 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.
+
'''Chain:''' The blockchain chain where the smart contract resides. It can either be "Avalanche" or "BinanceSmartChain".
  
'''Contract Address:''' The address of the smart contract on which the function will be executed.
+
'''Contract Address:''' The address of the smart contract from which you are calling the function.
  
'''Function Name:''' The specific function that is to be executed on the smart contract.
+
'''Function Name:''' The name of the function you are calling 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.
+
'''Parameters:''' The parameters that are to be passed to the function. They must match the parameters expected by the smart contract function.  
  
 
== Return Value ==
 
== Return Value ==
  
The function returns a string that represents the result of the executed smart contract function.
+
This function returns a string value, which depends on the output of the function being called on the smart contract.  
  
 
== Example ==
 
== Example ==
  
 
<pre>
 
<pre>
ui console view
+
log("Smart Contract Function Output: {$run contract function("BinanceSmartChain","0x000...","swapExactTokensForETH","[\"1000000000000000000\",\"0\",\"[0x00...,0x...]\",\"clientAddress\",\"1636575577\"]")}")
config defi wallet("your private key here")
+
log("Smart Contract Function Result: {$run contract function("BinanceSmartChain","0xBCfCcbde45cE874adCB698cC183deBcF17952812","getReserves","")}")
+
 
</pre>
 
</pre>
  
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 function will vary significantly depending on the smart contract and function being called.
  
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:
+
Always remember to replace "0x000..." and other placeholders with actual addresses and values. Also, the parameters must be passed in a correct format; otherwise, the function call will fail.
  
<blockquote>
+
NOTE: Interacting with smart contracts can lead to irreversible actions. Please make sure to understand what function you are running fully.
Smart Contract Function Result: 0x4a81748738792a0a8c21c0ff6f5f7c8cb6e79e30
+
</blockquote>
+

Revision as of 19:06, 4 July 2023

$run contract function is a function that runs a specified function on a smart contract residing on a specific blockchain.

This function interacts with smart contracts and can execute functionality like transferring tokens or calling view functions.

Parameters

Chain: The blockchain chain where the smart contract resides. It can either be "Avalanche" or "BinanceSmartChain".

Contract Address: The address of the smart contract from which you are calling the function.

Function Name: The name of the function you are calling on the smart contract.

Parameters: The parameters that are to be passed to the function. They must match the parameters expected by the smart contract function.

Return Value

This function returns a string value, which depends on the output of the function being called on the smart contract.

Example

log("Smart Contract Function Output: {$run contract function("BinanceSmartChain","0x000...","swapExactTokensForETH","[\"1000000000000000000\",\"0\",\"[0x00...,0x...]\",\"clientAddress\",\"1636575577\"]")}")

The output of this function will vary significantly depending on the smart contract and function being called.

Always remember to replace "0x000..." and other placeholders with actual addresses and values. Also, the parameters must be passed in a correct format; otherwise, the function call will fail.

NOTE: Interacting with smart contracts can lead to irreversible actions. Please make sure to understand what function you are running fully.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox