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.
- 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
- Every digital asset is linked to an issuer in Taurus-CAPITAL.
- Find its ID with List issuers info. If it is not there, create it with Create an issuer.
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
- If it already is, import it instead with Import a digital asset.
The IDS you will need
The flow uses several IDs. Each one comes from a different call, and they are easy to mix up.
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)orburn(address,uint256).
Read the rules in force with List governance rules.
- 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.
- Skip this step if you deploy from an existing template. Find its ID with List contract templates info.
- Otherwise, create it with Create a contract template:
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.
This example uses a template whose constructor takes admin and a tuple ERC20Attributes_. Use the constructor of your own template.
Address ID ≠ Address itself. The Taurus-PROTECT address that deploys, pays the fees, and sends later calls. Find your addressID with List addresses.
How to write the constructor values
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:
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:
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:
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.
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[].hashis 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
contractAddressentry in the response. You need it for the next step. It looks like this:
b. Check on the whitelisting request
Call List whitelisted addresses for approval, filtered on the new smart contract’s address (from the step above):
- The entry’s
idis thewlaId. 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:
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.
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.
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”:
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
Keep from the response: the digital asset id.
The token now appears in Taurus-CAPITAL under Digital assets → Smart contracts, marked as imported.