Pre-Requisite: Run a Writer Node

We are assuming you already have a writer node deployed and permissioned in one of the LACChain Networks orchestrated by LACNet. If not, please see the steps to deploy a node and the networks available.

NOTE: If you deployed your node with docker or kubernetes, skip section "Run the Relaysigner Component" and go to section "Adapt your Smart Contract to our GAS Distribution Protocol".

Run the Relaysigner Component

Wait until your writer node has synced the entire blockchain. Then, check that you have the environment variable WRITER_KEY set on your node

					$ env

In case you don’t have the WRITER_KEY variable in your environment, please set this variable with the content of the file /lacchain/data/key

					$ export WRITER_KEY=PRIVATE_KEY  //where PRIVATE_KEY is content of /lacchain/data/key

Enter the node’s console and run the following commands:

					$ cd /root/lacchain/gas-relay-signer
$ systemctl import-environment WRITER_KEY
$ service relaysigner start

Verify relaysigner is working well, go to the log file.

					$ cd /root/lacchain/gas-relay-signer/log 
$ tail -100 idbServiceLog.log

The first lines should be something like this:

					General Logger:	2021/11/23 16:19:19 main.go:60: smartContract=0x3B62E51E37d090453600395Ff1f9bdf4d7398404 AgentKey=/home/adrian/.ethereum/keystore/UTC--2020-06-26T19-00-23.241896464Z--bceda2ba9af65c18c7992849c312d1db77cf008e
General Logger:	2021/11/23 16:19:19 main.go:65: Init RelaySigner
General Logger:	2021/11/23 16:19:19 client.go:46: Connected to Ethereum Node: ws://localhost:4546


That means relaysigner is configured and working well.

Remeber to have sent your node address. If not, then please, run these commands on your node and copy your node address:

					$ cd /root/lacchain/data
$ cat nodeAddress

Now send an email with the subject “permissioning account node” to [email protected] writing as content your node address and your the name of your organization.

When you receive the response, your node will be ready to send transactions or deploy contracts.

Adapt your Smart Contract to our GAS Distribution Protocol

As the sender with which the transactions arrive at the receipient contract is the address of the RelayHub contract, a mechanism is necessary to obtain the original sender of the client or user who sent the transaction.

To make this possible, we take advantage of the atomicity of the execution of the transactions in the EVM. That is, every time a transaction is sent to the RelayHub, the address of the original sender is stored, which is then retrieved by making a call to the RelayHub from the recipient contract.

This function to obtain the original sender is located in an abstract contract, which has to be inherited by all the contracts that will be deployed in the network.

The abstract contract to inherit is BaseRelayRecipient. After inherit this contract you have to update the value of the internal variable trustedForwarder by one of following address.

On Open-protestnet = 0xa4B5eE2906090ce2cDbf5dfff944db26f397037D

On Mainnet = 0xEAA5420AF59305c5ecacCB38fcDe70198001d147

Next, you should use _msgSender() function instead msg.sender.

(image below show you as use _msgSender() instead msg.sender)

Finally compile your contract.

Additionally, you can find and example in Storage2.sol

Considerations before to send transactions

Since everything is sent by a proxy(Gas model smart contract), on our side we have events that indicate the success or failure of transactions.
To parse events generated by proxy(Gas model smart contract), these are the smart contract address on each network:

On Open-protestnet = 0xB9e9C5C528C266f2A1C7Eeec1975595232C8E475

On Mainnet = 0x34B220Ef63dea567eDf6d540316B5a3f4831Cf6c

At the moment we have the following events on this proxy:
0x79f72f9d… = Relayed(address indexed sender, address indexed nodeAddress) : It means that the transaction was accepted.
0x548af85d7b… = TransactionRelayed(address indexed relay, address indexed from, address indexed to, bool executed, bytes output) : It means that the transaction was sent to the destination contract.
When the transaction is executed, to get the revert reason you must do it using the TransactionRelayed and parsing the bytes of the output parameter.
0x260359ee… = GasUsedByTransaction(address node, uint blockNumber, uint gasUsed, uint gasLimit, uint gasUsedLastBlocks) : How much GAS was consumed in the execution of the transaction.
0x8a14d1d720… = ContractDeployed(address indexed relay, address indexed sender, address contractDeployed) : It means that the contract was deployed successfully.
0xc62bb53370… = BadTransactionSent(address node, address originalSender, ErrorCode errorCode); : An error was encountered while executing the transaction. Depending on the errorCode value, it can be:
0: Block GAS limit exceeded
1: The person who sent the transaction is not the same person who signed it.
2: The nonce is not correct.
3: The GAS limit sent is higher than the amount of GAS the node has.
4: The destination contract has no code, that is, the destination address is empty.
5: Trying to deploy a contract with 0 bytes.
6: The transaction is not well signed.
7: The destination of the transaction is a network management contract.


Frequent errors and how to solve

Some frequent errors after send a transaction are the following:

  1. After send a transaction to deploy a smart contract a get 0x00000000000000000000000000000000000000 as my new contract address. This happen because you ran out of gas, the solution is increase your gas limit.
  2. I am getting the message: “gas limit exceeds block gas limit“. This happen because you node has a GAS limit per block and your transaction will exceed that limit.
  3. My transaction was reverted, but I can’t see the message error. To see revert reason to must parse the bytes of the output parameter at TransactionRelayed event.
  4. I am sending transactions, but I can’t see these in explorer or I don’t get the receipt. That happen because your transaction is being rejected. To see that message, please make sure in file /lacchain/start-pantheon.sh this flag is set on true and restart your node:

Considerations for mainnet

On mainnet, the nodes have a membership, so the deployment of contracts is limited to the GAS limit assigned to the node. In case of an organization requires a larger quantity to deploy its contract, please send an email to [email protected] indicating that it is required one or two days with the amount of GAS to deploy the contract.

Copyright 2023 © All rights Reserved. Designed by LACNet