Skip to navigation

Smart contracts on EVM blockchains: step by step (API)

Deploy a token smart contract from a contract template, through the Taurus-CAPITAL and Taurus-PROTECT APIs.

In short
  • You create a contract template, or use the genuine contract template provided from Taurus
  • You create the contract and issue it
  • Taurus-PROTECT approves and sends the deployment, then automatically asks for approval to whitelist the new smart contract’s address.
  • Once both are approved, the smart contract is live, and Taurus-PROTECT can call it.
  • To fully view and manage the token in Taurus-CAPITAL, you import it as a digital asset.
  • This page applies to Ethereum and other EVM blockchains.
  • On these blockchains, the token is a smart contract:
    • you deploy it from a contract template;
    • the smart contract defines which controls the issuer has.

All examples use https://your-protect-instance.example.com. Replace it with your own Taurus-PROTECT instance.

Before you start

Your technical users have the right roles

  • To create the template and deploy: Capital Operator and RequestCreator.
  • To call a function after deployment, for example mint: RequestCreator and TPUser.
  • To approve the deployment, a mint, or a control: RequestApprover, in the group your governance rule names.
  • To approve the whitelisting of the smart contract: WhitelistedAddressApprover.
  • Every approver needs a registered signing key: an ECDSA key on the P-256 curve. See Signing for approval.

Your issuer is registered

The deploying address can pay the fees

  • The address that sends the deployment pays its fees in the blockchain’s own currency, for example ETH on Ethereum.
  • Find its ID with List addresses.
  • Choose the address that will also be the smart contract’s admin. It then holds the right to mint, and later calls can be sent from it.

The smart contract is not deployed yet

The IDS you will need

The flow uses several IDs. Each one comes from a different call, and they are easy to mix up.

IDWhat it identifiesHow to get it
Template IDThe contract templateThe response of step 2, or List contract templates info
Address IDAddress ID ≠ Address itself. The Taurus-PROTECT ID to identify the address that deploys, pays the fees, and sends later callsList addresses
Request IDThe deployment request ID, and later each mint or controlList requests for approval
Whitelisted address ID (wlaId)The whitelisted address of the new smart contractGet a request (GET /api/rest/v1/requests/{id}), after the broadcast. Also returned in step 6.
Contract instance IDThe deployed smart contract in Taurus-CAPITALList contract instances info
Issuer IDThe issuer of the tokenList issuers info
Digital asset IDThe token in Taurus-CAPITALThe response of step 8

Steps

1. Check the governance rules

Who: SuperAdmin.

Two kinds of Governance > Transaction rules must exist for your EVM blockchain:

  • Contract deployment: who approves a new smart contract on this blockchain.
  • Contract interaction: one rule for each function you plan to call, for each contract type, for example mint(address,uint256) or burn(address,uint256).

Read the rules in force with List governance rules.

Rules are tied to the contract type
  • A rule for one contract type does not cover another.

A change to the governance rules only takes effect after SuperAdmins sign it.

2. Create the contract template

Who: Capital Operator.

POST https://your-protect-instance.example.com/api/rest/v1/capital/contract-templates
Request body
{
"name": "My token v1",
"blockchain": "ETH",
"contractType": "Custom",
"contractCode": "<base64-build-json>",
"tokenTypes": ["equity"],
"author": "<author>",
"supportFeepayer": false,
"isUpgradeable": false
}
FieldWhat to enter
nameA name for internal use, for example the contract type and version
blockchainThe blockchain the template can be deployed on. A template can only be used on this blockchain.
contractTypeThe type of smart contract. With Custom, Taurus-PROTECT uses GENERIC for governance rules and calls (see step 1).
contractCodeThe build JSON from your compiler, encoded in standard base64, on one line.
tokenTypesThe asset types the template can be used for, as a list: asset, equity, debt, convertible, utility_token, currency, fund_shares, structured_products, commodity or nft
authorWho is responsible for the template
supportFeepayertrue only if the smart contract lets a fee payer pay its transaction fees
isUpgradeableMarks the template as upgradeable. Upgrading a deployed proxy to a new implementation is done separately, with Upgrade an EVM proxy.

Keep from the response: the template ID.

Check: the template’s ABI contains every function you plan to call, for example mint. A smart contract without a mint function can never create new units.

3. Deploy the contract instance

Who: Capital Operator, with the RequestCreator role.

Deploy it with Deploy an EVM contract instance. This creates the deployment request in Taurus-PROTECT.

POST https://your-protect-instance.example.com/api/rest/v1/capital/contract-instances/evm/deploy

This example uses a template whose constructor takes admin and a tuple ERC20Attributes_. Use the constructor of your own template.

Request body
{
"genericData": {
"contractTemplateID": "<template-id>",
"blockchain": "ETH",
"network": "mainnet",
"fromAddressID": "<address-id>",
"whitelistContract": true
},
"parameters": {
"constructorParameters": {
"admin": "<admin-address>",
"ERC20Attributes_": "{\"name\":\"My Token\",\"symbol\":\"MTK\",\"decimalsIrrevocable\":18}"
}
}
}

Address ID ≠ Address itself. The Taurus-PROTECT address that deploys, pays the fees, and sends later calls. Find your addressID with List addresses.

FieldWhat to enter
contractTemplateIDThe template ID from step 2
blockchain, networkThe blockchain and network of the template, for example ETH and mainnet
fromAddressIDThe AddressID that sends the deployment and pays its fees
whitelistContracttrue: Taurus-PROTECT then requests the whitelisting of the new smart contract’s address automatically (step 5)
gasLimit, gasPrice, feeLimitOptional. Leave them out unless your technical team advises otherwise.
feepayerIDOptional. A fee payer that pays the fees instead of the deploying address, if the template supports it.
constructorParametersThe constructor values, as a map of argument name to value. See the table below.

How to write the constructor values

RuleExample
The key is the constructor argument’s name, exactly as in the ABI, including caseadmin, ERC20Attributes_
A tuple is a JSON object with the component names, written as a string"{\"name\":\"My Token\",\"symbol\":\"MTK\",\"decimalsIrrevocable\":18}"
Constructor values are permanent

Once deployed, the constructor values, including the admin and the decimals, can never be changed.

4. Approve the deployment

Who: the approvers named in the contract deployment rule, with the RequestApprover role.

Approving takes three actions: get the request’s hash, sign it on your side, then send the signature.

a. Get the request ID and the hash of the request

Call List requests for approval:

GET https://your-protect-instance.example.com/api/rest/v1/requests/for-approval

Keep from the response: the request ID. The list shows every request waiting for your approval, so check that you pick the right one, usually the most recent.

Call Get a request with the request ID from step 3:

GET https://your-protect-instance.example.com/api/rest/v1/requests/<request-id>

Copy metadata.hash from the response: 64 hexadecimal characters.

b. Sign the hash

Sign it with the approver’s private key, as described in Signing for approval. The result is the signature: Base64 text.

Keep the private key on the approver’s machine. Never share it.

c. Send the approval

Call Approve a request with the request ID and the signature:

POST https://your-protect-instance.example.com/api/rest/v1/requests/approve
Request body
{
"ids": ["<request-id>"],
"comment": "Approve deployment of My token",
"signature": "<base64-signature>"
}

The response confirms the signature: {"signedRequests": "1", "signatures": "1"}. Once all approvals are in, the deployment is signed in the HSM and sent to the blockchain.

Check the request status with Get a request: status moves to APPROVED, then BROADCASTING. You will need the request ID to call the API. Taurus-PROTECT has signed the deployment in the HSM and queues it for the blockchain.

5. Wait for the broadcast, then approve the whitelisting

Who: the approvers named in the address whitelisting rules, with the WhitelistedAddressApprover role.

The whitelisting request does not exist until the deployment is broadcast, usually a few minutes after the approval in step 4.

a. Wait for the broadcast

To check the request status, call Get a request with the deployment’s request ID.

GET https://your-protect-instance.example.com/api/rest/v1/requests/<request-id>

When the status moved to ‘CONFIRMED’, it means that the deployment has been broadcast.

The smart contract is now LIVE on the chain.

  • Once the deployment has been broadcast, signedRequests[].hash is the transaction hash. You can look it up in a public blockchain explorer.

  • While the contract is deployed, Taurus-PROTECT creates the whitelisting request within a few minutes.

  • Look for the contractAddress entry in the response. You need it for the next step. It looks like this:

    {
    "id": "<attribute-id>",
    "key": "contractAddress",
    "value": "<contract-address>",
    "contentType": "text/plain"
    }

b. Check on the whitelisting request

Call List whitelisted addresses for approval, filtered on the new smart contract’s address (from the step above):

GET https://your-protect-instance.example.com/api/rest/v1/whitelists/addresses/for-approval?addressType=contract&query=<contract-address>
  • The entry’s id is the wlaId. It is labelled <contract type> - <contract address> (request <request-id>).
  • Copy its metadata.hash. This list is the only place to get it: the hash is not returned when the whitelisting request is created.

c. Sign the hash

Sign it as in step 4. This needs a new signature: the previous one does not work here.

d. Send the approval

Call Approve a whitelisted address:

POST https://your-protect-instance.example.com/api/rest/v1/whitelists/addresses/approve
Request body
{
"ids": ["<wlaId>"],
"comment": "Whitelist My token contract",
"signature": "<base64-signature>"
}

After the approval of the whitelisted address request, Taurus-PROTECT can now call the smart contract.

6. Find the contract instance

Once the deployment is confirmed, Taurus-CAPITAL records the smart contract as a contract instance. Note that the contract instance is not visible in the Taurus-CAPITAL interface yet. It appears there once you import it as a digital asset later.

Call List contract instances info, using the contract address.

GET https://your-protect-instance.example.com/api/rest/v1/capital/contract-instances/info?address=<contract-address>&limit=10
Response
{
"result": {
"contractInstancesInfo": [
{
"id": "<contract-instance-id>",
"address": "<contract-address>",
"contractTemplateID": "<template-id>",
"wlaId": "<wlaId>",
"blockchain": "ETH",
"network": "mainnet",
"contractName": "My token v1",
"contractType": "custom"
}
],
"totalItems": "1"
}
}

Keep from the response: the contract instance id.

7. Check that the smart contract answers

Read its name with Execute an EVM call. It is read-only: no approval and no fee.

Use the contract instance id (from step 6) here.

POST https://your-protect-instance.example.com/api/rest/v1/capital/contract-instances/<contract-instance-id>/evm/call
Request body
{
"fromAddressID": "<address-id>",
"data": "0x06fdde03"
}

Tip: You should be able to find the fromAddressID in the call you ran in step 3. Address ID ≠ Address itself.

data is the function selector: it tells the smart contract which function to run. 0x06fdde03 is the standard selector of name(). To read another value, use that function’s selector, for example 0x95d89b41 for symbol().

The answer in the sample is the token name, ABI-encoded in hexadecimal: its position, its length, then its characters. For “My Token”:

…0020 …0008 4d7920546f6b656e…
start length M y T o k e n

8. Import it as a digital asset

Who: Capital Operator.

For you to view and manage the contract as a ‘digital asset’ in Taurus CAPITAL, import it with Import a digital asset

POST https://your-protect-instance.example.com/api/rest/v1/capital/digital-assets/import
Request body
{
"issuerID": "<issuer-id>",
"contractTemplateID": "<template-id>",
"contractAddress": "<contract-address>",
"contractInstanceID": "<contract-instance-id>",
"digitalAssetType": "Equity",
"issuanceName": "My token",
"blockchain": "ETH",
"network": "mainnet"
}
FieldWhat to enter
issuerIDThe issuer of the token. Find it with List issuers info.
contractTemplateIDThe template ID from step 2
contractAddressThe contractAddress
contractInstanceIDThe contract instance ID from step 6
digitalAssetTypeThe asset type, for example Equity
issuanceNameThe name shown in Taurus-CAPITAL. It is not written to the blockchain.
blockchain, networkThe same as in step 3

Keep from the response: the digital asset id.

The token now appears in Taurus-CAPITAL under Digital assets → Smart contracts, marked as imported.

Errors

ErrorCauseWhat to do
E002-MISSING_GOVERNANCE_RULENo contract interaction rule for this function and contract type. No request is created, and no fee is charged.A SuperAdmin creates the rule, with GENERIC for a Custom template; once it is signed, send the call again.
invalid signatureThe signature was made over a different hash, for example that of another requestSign the metadata.hash of the request you approve. The error message shows the expected hash.
The token is not listed in Taurus-CAPITALThe deployment creates a contract instance, not a digital assetImport it (step 8).
A call rejected (reverted) by the blockchainThe function or its values do not match the smart contract, or the sending address does not hold the roleCheck the ABI and the sending address’s role. The fee is still charged.