Creating A Smart Contract Call Request
POST /api/rest/v1/requests/outgoing/contracts/call
Basic Description
This endpoint is used to create a Smart Contract Deployment Request through Taurus-PROTECT.
This endpoint would accept a POST Request with a JSON payload containing the Smart Contract Deployment Request details. The bytecode
, fromAddressId
, constructor
and generateWhitelistedAddress
are the only required parameters that must be included within the JSON payload.
Prerequisites
Required Roles
Certain API endpoints require that the user has a specific role in order to access them. Roles are used to restrict access to certain functionality within the system and ensure that only authorized users are able to perform specific actions.
Here is the list of required Roles for this particular endpoint:
- RequestCreator
- TPUser
To find out more about roles, please refer to the following page in the Taurus User Guides.
Required Input Parameters
Certain API endpoints require specific input parameters. Here is the list of Required Input Parameters for this particular endpoint:
- fromAddressId: Address ID in Protect that should call the contract
- toWhitelistedAddressId: Whitelisted address ID of the contract, visible on the “Whitelisted addresses” page in the UI, or as used during the whitelisted address approval process via API
- method: Signature and arguments of the function call. Supported argument types are the same as for contract deployment.
Additional fields such as gasLimit, gasPriceLimit or feeLimit that are common to all request may (and should) also be specified in a production setting.
Preconditions
It is important to note that the selected Smart Contract needs to pre-exist.
Mint Example
You can find a basic example in cURL below.
Please note that you will need to update the BASEURL
and the APITOKEN
for the command to function.
In this example, Taurus-PROTECT has created a new Smart Contract Call Request from Address XXXXXXXXXXXXX and Mint 300 tokens to address 0x72694cd89282bafc520e02965c6ccdf63d12984a (called from an admin account of the contract):
export BASEURL=https://taurus-protect-instance.com
export APIToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiZXh0ZXJuYWxVc2VySUQiOiJ0ZWFtMUV4dGVybmFsVXNlcklEIiwidGVuYW50SUQiOjEsImNhcGl0YWxUZW5hbnRJRCI6MSwiZmlyc3RuYW1lIjoiSm9obiIsImxhc3RuYW1lIjoiRG9lIiwicm9sZXMiOlsidHB1c2VyIl0sImVtYWlsIjoidGVhbTFAYmFuay5jb20iLCJ1c2VybmFtZSI6InRlYW0xIiwiand0X3JlbmV3YWJsZV9hbW91bnQiOjAsImlzX3RvdHBfZW5hYmxlZCI6ZmFsc2UsImF1dGhfc3RhdHVzIjoiU1VDQ0VTUyIsImxhc3RfbG9naW4iOiIyMDIzLTAxLTAxVDAwOjAwOjAwLjE0OTc0NDIzMloiLCJsb2dnZWRfaW5fd2l0aF9zc28iOmZhbHNlLCJrZXkiOiIiLCJleHAiOjE2ODEyMTkyNzYsImlhdCI6MTY4MTIxNzQ3Nn0.K_85arIrigpkN1yHttCydpeT6oVg2c6PyQnuji907Og
curl --location "$BASEURL/api/rest/v1/requests/outgoing" \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header "Authorization: Bearer $APIToken" \
--data '"method": {
"functionSignature": "mint(address,uint256)",
"args": [
{
"name": "destination",
"type": "address",
"value": {
"primitive": "0x72694cd89282bafc520e02965c6ccdf63d12984a"
}
},
{
"name": "amount",
"type": "uint256",
"value": {
"primitive": "300"
}
}
]
}
'
Burn Example
You can find a basic example in cURL below.
Please note that you will need to update the BASEURL
and the APITOKEN
for the command to function.
In this example, Taurus-PROTECT has created a new Smart Contract Call Request from Address XXXXXXXXXXXX to Burn 500 tokens from address 0x72694cd89282bafc520e02965c6ccdf63d12984a (called from an admin account of the contract):
export BASEURL=https://taurus-protect-instance.com
export APIToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiZXh0ZXJuYWxVc2VySUQiOiJ0ZWFtMUV4dGVybmFsVXNlcklEIiwidGVuYW50SUQiOjEsImNhcGl0YWxUZW5hbnRJRCI6MSwiZmlyc3RuYW1lIjoiSm9obiIsImxhc3RuYW1lIjoiRG9lIiwicm9sZXMiOlsidHB1c2VyIl0sImVtYWlsIjoidGVhbTFAYmFuay5jb20iLCJ1c2VybmFtZSI6InRlYW0xIiwiand0X3JlbmV3YWJsZV9hbW91bnQiOjAsImlzX3RvdHBfZW5hYmxlZCI6ZmFsc2UsImF1dGhfc3RhdHVzIjoiU1VDQ0VTUyIsImxhc3RfbG9naW4iOiIyMDIzLTAxLTAxVDAwOjAwOjAwLjE0OTc0NDIzMloiLCJsb2dnZWRfaW5fd2l0aF9zc28iOmZhbHNlLCJrZXkiOiIiLCJleHAiOjE2ODEyMTkyNzYsImlhdCI6MTY4MTIxNzQ3Nn0.K_85arIrigpkN1yHttCydpeT6oVg2c6PyQnuji907Og
curl --location "$BASEURL/api/rest/v1/requests/outgoing" \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header "Authorization: Bearer $APIToken" \
--data '"method": {
"functionSignature": "burn(address,uint256)",
"args": [
{
"name": "source",
"type": "address",
"value": {
"primitive": "0x72694cd89282bafc520e02965c6ccdf63d12984a"
}
},
{
"name": "amount",
"type": "uint256",
"value": {
"primitive": "500"
}
}
]
}
'
Transfer example
You can find a basic example in cURL below.
Please note that you will need to update the BASEURL
and the APITOKEN
for the command to function.
In this example, Taurus-PROTECT has created a new Smart Contract Call Request from Address XXXXXXXXXXXX to transfer 100 tokens from address 0x72694cd89282bafc520e02965c6ccdf63d12984a (called from the address where the funds should be from):
export BASEURL=https://taurus-protect-instance.com
export APIToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiZXh0ZXJuYWxVc2VySUQiOiJ0ZWFtMUV4dGVybmFsVXNlcklEIiwidGVuYW50SUQiOjEsImNhcGl0YWxUZW5hbnRJRCI6MSwiZmlyc3RuYW1lIjoiSm9obiIsImxhc3RuYW1lIjoiRG9lIiwicm9sZXMiOlsidHB1c2VyIl0sImVtYWlsIjoidGVhbTFAYmFuay5jb20iLCJ1c2VybmFtZSI6InRlYW0xIiwiand0X3JlbmV3YWJsZV9hbW91bnQiOjAsImlzX3RvdHBfZW5hYmxlZCI6ZmFsc2UsImF1dGhfc3RhdHVzIjoiU1VDQ0VTUyIsImxhc3RfbG9naW4iOiIyMDIzLTAxLTAxVDAwOjAwOjAwLjE0OTc0NDIzMloiLCJsb2dnZWRfaW5fd2l0aF9zc28iOmZhbHNlLCJrZXkiOiIiLCJleHAiOjE2ODEyMTkyNzYsImlhdCI6MTY4MTIxNzQ3Nn0.K_85arIrigpkN1yHttCydpeT6oVg2c6PyQnuji907Og
curl --location "$BASEURL/api/rest/v1/requests/outgoing" \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header "Authorization: Bearer $APIToken" \
--data '"method": {
"functionSignature": "transfer(address,uint256)",
"args": [
{
"name": "destination",
"type": "address",
"value": {
"primitive": "0x836395de4e81364121fa4718bc2a90268745c6cf"
}
},
{
"name": "amount",
"type": "uint256",
"value": {
"primitive": "100"
}
}
]
}
'
These pieces of code send POST requests to https://your-protect-instance.example.com/api/rest/v1/requests/outgoing/contracts/deploy with the JSON string in the request body.
Call Result
A successful response for the POST call to create a Smart Contract call Request through Taurus-PROTECT might look like this:
{
"result": {
"id": "4201467",
"tenantId": "12",
"currency": "ETH",
"envelope": [...]
[...]
Taurus-PROTECT responds with a JSON object containing the Request details, including the Call Request status
and the newly assigned Request id
.
Requirements for Future Use
For this particular endpoint, we need to store the Requestid
as it will be required in the next step where we will sign the Transaction Request.
You can find the Swagger-generated page for this endpoint in the following link.
Updated 22 days ago