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

Copyright 2023 © All rights Reserved. Designed by LACNet