(smartContractManagement)
The Smart contract management is an abstraction on top of our Transaction Manager and it allow you to build and automate your smart contract transaction easily, without struggling with the ABI and params encoding. With it you can:
- Deploying smart contract: Deploy audited contract from our library or your own smart contract
- Import existing contract: Import existing contract to view them on your dashboard and interact with them.
- Interact: Read state and interact with the smart contract previously deployed or imported
- call - Execute Smart Contract Function
- delete - Delete a smart contract
- deployFromBytecode - Deploy from bytecode (your own contract)
- deployFromTemplate - Deploy Smart Contract from Template
- getAll - Get all smart contracts
- getFunctions - Retrieves Smart Contract Functions and Events
- getOne - Get a single smart contract
- importExisting - Import Existing Smart Contract
- read - Query Smart Contract Function
- update - Update a smart contract
Calls a specific function within a deployed smart contract, enabling interactions such as executing transactions or querying state. The method parameters, including the smart contract address and network, need to be specified.
import { Starton } from "@starton/sdk";
const starton = new Starton({
startonApiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await starton.smartContractManagement.call({
callDto: {
functionName: "<value>",
params: [
"TestToken",
"TEST",
"1000000000000000000000000",
"0x298e760768c8481780397eE28A127eAd584df4ee",
],
signerWallet: "<value>",
},
address: "0x820f8728E32519b9C91B2406BF48AF80711aFecD",
network: "polygon-mumbai",
simulate: false,
});
// Handle the result
console.log(result)
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.CallSmartContractRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
Promise<operations.CallSmartContractResponse>
Error Object | Status Code | Content Type |
---|---|---|
errors.CallSmartContractResponseBody | 400 | application/json |
errors.CallSmartContractSmartContractManagementResponseBody | 404 | application/json |
errors.CallSmartContractSmartContractManagementResponseResponseBody | 422 | application/json |
errors.CallSmartContractSmartContractManagementResponse500ResponseBody | 500 | application/json |
errors.SDKError | 4xx-5xx | / |
Deletes a specific smart contract based on network and address.
import { Starton } from "@starton/sdk";
const starton = new Starton({
startonApiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await starton.smartContractManagement.delete({
address: "8653 Vaughn Hills",
network: "polygon-mumbai",
});
// Handle the result
console.log(result)
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.DeleteSmartContractRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
Promise<operations.DeleteSmartContractResponse>
Error Object | Status Code | Content Type |
---|---|---|
errors.DeleteSmartContractResponseBody | 400 | application/json |
errors.DeleteSmartContractSmartContractManagementResponseBody | 404 | application/json |
errors.SDKError | 4xx-5xx | / |
Deploys a smart contract from bytecode and returns transaction details.
import { Starton } from "@starton/sdk";
import { Type } from "@starton/sdk/sdk/models/shared";
const starton = new Starton({
startonApiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await starton.smartContractManagement.deployFromBytecode({
deployFromBytecodeDto: {
abi: [
{
type: Type.Event,
},
],
bytecode: "<value>",
name: "<value>",
network: "<value>",
params: [
"TestToken",
"TEST",
"1000000000000000000000000",
"0x298e760768c8481780397eE28A127eAd584df4ee",
],
signerWallet: "<value>",
},
simulate: false,
});
// Handle the result
console.log(result)
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.DeployFromBytecodeSmartContractRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
Promise<operations.DeployFromBytecodeSmartContractResponse>
Error Object | Status Code | Content Type |
---|---|---|
errors.DeployFromBytecodeSmartContractResponseBody | 400 | application/json |
errors.DeployFromBytecodeSmartContractSmartContractManagementResponseBody | 404 | application/json |
errors.DeployFromBytecodeSmartContractSmartContractManagementResponseResponseBody | 422 | application/json |
errors.DeployFromBytecodeSmartContractSmartContractManagementResponse500ResponseBody | 500 | application/json |
errors.SDKError | 4xx-5xx | / |
Deploy from Starton audited smart contract template.
import { Starton } from "@starton/sdk";
const starton = new Starton({
startonApiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await starton.smartContractManagement.deployFromTemplate({
deployFromTemplateDto: {
name: "TestToken",
network: "polygon-mumbai",
params: [
"TestToken",
"TEST",
"1000000000000000000000000",
"0x298e760768c8481780397eE28A127eAd584df4ee",
],
signerWallet: "0x298e760768c8481780397eE28A127eAd584df4ee",
templateId: "ERC20_META_TRANSACTION",
},
simulate: false,
});
// Handle the result
console.log(result)
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.DeployFromTemplateSmartContractRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
Promise<operations.DeployFromTemplateSmartContractResponse>
Error Object | Status Code | Content Type |
---|---|---|
errors.DeployFromTemplateSmartContractResponseBody | 400 | application/json |
errors.DeployFromTemplateSmartContractSmartContractManagementResponseBody | 404 | application/json |
errors.DeployFromTemplateSmartContractSmartContractManagementResponseResponseBody | 500 | application/json |
errors.SDKError | 4xx-5xx | / |
Fetches and returns the list of smart contracts.
import { Starton } from "@starton/sdk";
const starton = new Starton({
startonApiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await starton.smartContractManagement.getAll({
address: "0x820f8728E32519b9C91B2406BF48AF80711aFecD",
includeAbi: true,
includeCompilationDetails: true,
limit: 20,
network: "polygon-mumbai",
page: 0,
});
for await (const page of result) {
// handle page
}
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.GetAllSmartContractRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
Promise<operations.GetAllSmartContractResponse>
Error Object | Status Code | Content Type |
---|---|---|
errors.GetAllSmartContractResponseBody | 400 | application/json |
errors.SDKError | 4xx-5xx | / |
Provides a list of the available read and write functions, as well as events, of a specified smart contract. This can be used to understand how to interact with the contract.
import { Starton } from "@starton/sdk";
const starton = new Starton({
startonApiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await starton.smartContractManagement.getFunctions({
address: "0x820f8728E32519b9C91B2406BF48AF80711aFecD",
network: "polygon-mumbai",
});
// Handle the result
console.log(result)
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.GetAvailableFunctionsSmartContractRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
Promise<operations.GetAvailableFunctionsSmartContractResponse>
Error Object | Status Code | Content Type |
---|---|---|
errors.GetAvailableFunctionsSmartContractResponseBody | 400 | application/json |
errors.GetAvailableFunctionsSmartContractSmartContractManagementResponseBody | 404 | application/json |
errors.GetAvailableFunctionsSmartContractSmartContractManagementResponseResponseBody | 500 | application/json |
errors.SDKError | 4xx-5xx | / |
Fetches details of a specific smart contract based on network and address.
import { Starton } from "@starton/sdk";
const starton = new Starton({
startonApiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await starton.smartContractManagement.getOne({
address: "0x820f8728E32519b9C91B2406BF48AF80711aFecD",
includeAbi: true,
includeCompilationDetails: true,
network: "polygon-mumbai",
});
// Handle the result
console.log(result)
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.GetOneSmartContractRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
Promise<operations.GetOneSmartContractResponse>
Error Object | Status Code | Content Type |
---|---|---|
errors.GetOneSmartContractResponseBody | 400 | application/json |
errors.GetOneSmartContractSmartContractManagementResponseBody | 404 | application/json |
errors.SDKError | 4xx-5xx | / |
Import an already deployed smart contract into the project. This requires providing the smart contract’s address, ABI, and the network it’s deployed on.
import { Starton } from "@starton/sdk";
import { StateMutability, Type } from "@starton/sdk/sdk/models/shared";
const starton = new Starton({
startonApiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await starton.smartContractManagement.importExisting({
abi: [
{
inputs: {
name: "<value>",
type: "<value>",
},
stateMutability: StateMutability.Nonpayable,
type: Type.Constructor,
},
],
address: "0x1C1f7A4d7F853856b964947CA03B92993D3ef40e",
creationHash: "0x55b782a3db6d7b8c1949536110dcaaac69b4f83455959ab2839c09c2ed2ab1da",
description: "Test minimal contract tests.",
name: "Minimal contract tests.",
network: "polygon-mumbai",
params: [
"TestToken",
"TEST",
"1000000000000000000000000",
"0x298e760768c8481780397eE28A127eAd584df4ee",
],
templateId: "ERC721_META_TRANSACTION",
});
// Handle the result
console.log(result)
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
shared.ImportSmartContractDto | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
Promise<operations.ImportExistingSmartContractResponse>
Error Object | Status Code | Content Type |
---|---|---|
errors.ImportExistingSmartContractResponseBody | 400 | application/json |
errors.SDKError | 4xx-5xx | / |
Reads data from a smart contract by calling one of its functions without making any state changes on the blockchain. This is typically used for retrieving information from the contract.
import { Starton } from "@starton/sdk";
const starton = new Starton({
startonApiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await starton.smartContractManagement.read({
readDto: {
functionName: "<value>",
params: [
"TestToken",
"TEST",
"1000000000000000000000000",
"0x298e760768c8481780397eE28A127eAd584df4ee",
],
},
address: "0x820f8728E32519b9C91B2406BF48AF80711aFecD",
network: "polygon-mumbai",
});
// Handle the result
console.log(result)
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.ReadSmartContractRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
Promise<operations.ReadSmartContractResponse>
Error Object | Status Code | Content Type |
---|---|---|
errors.ReadSmartContractResponseBody | 400 | application/json |
errors.ReadSmartContractSmartContractManagementResponseBody | 404 | application/json |
errors.ReadSmartContractSmartContractManagementResponseResponseBody | 500 | application/json |
errors.SDKError | 4xx-5xx | / |
Updates and returns details of a specific smart contract based on network and address.
import { Starton } from "@starton/sdk";
const starton = new Starton({
startonApiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await starton.smartContractManagement.update({
updateSmartContractDto: {},
address: "0x820f8728E32519b9C91B2406BF48AF80711aFecD",
network: "polygon-mumbai",
});
// Handle the result
console.log(result)
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.UpdateSmartContractRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
Promise<operations.UpdateSmartContractResponse>
Error Object | Status Code | Content Type |
---|---|---|
errors.UpdateSmartContractResponseBody | 400 | application/json |
errors.UpdateSmartContractSmartContractManagementResponseBody | 404 | application/json |
errors.SDKError | 4xx-5xx | / |