> For the complete documentation index, see [llms.txt](https://docs.liquidapps.io/liquidapps-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.liquidapps.io/liquidapps-documentation/liquidx-stake-across-chains/getting-started-with-liquidx/use-dapp-network-services/smart-contract-steps.md).

# Smart Contract Steps

## Smart contract commands

### Unbox LiquidX box

We will unbox the `liquidx` box to give us all of the logic, contracts, and unit tests

```bash
mkir liquidx; cd liquidx
zeus unbox liquidx
```

### Create Contract

Create smart contract, or if you're using thise guide as a part of another guide, you can skip this and go to the compiling section

```bash
export MY_CONTRACT_NAME=
zeus create contract $MY_CONTRACT_NAME
cd zeus_boxes/contracts/eos
# edit MY_CONTRACT_NAME.cpp
cd ../../../
```

## Smart Contract Steps

#### `#define LIQUIDX`

At the smart contract level, the `liquidx` box must be unboxed and `#define LIQUIDX` must be added at the top of the smart contract which uses the DAPP Network services.&#x20;

{% hint style="info" %}
If you are already using an existing contract such as `tokenpegx` then this is already handled for you
{% endhint %}

### Adding files to Zeus

2 files must be added and 2 files deleted as to not conflict

#### `liquidx-mappings/sidechain_name.dappservices.json`

{% hint style="warning" %}
update `sidechain_name` to `chain_account`
{% endhint %}

`/zeus_boxes/liquidx/models/liquidx-mappings/sidechain_name.dappservices.json` - this maps the dappservices account on the mainnet to the dappservicex account name on the new chain

* `sidechain_name` - EOS mainnet account that has registered the chain
* `mainnet_account` - dappservices account on EOS mainnet
* `chain_account` - dappservicex account on new chain - enter the sidechain\_name as the scope for the [`chainentry`](https://bloks.io/account/liquidx.dsp?loadContract=true\&tab=Tables\&table=chainentry\&account=liquidx.dsp\&scope=CHAIN_NAME_HERE\&limit=100) table, the `dappservices_contract` key will list the account name needed

{% hint style="info" %}
chain\_account for jungle3 is [testdappxxxx](https://jungle3.bloks.io/account/testdappxxxx)
{% endhint %}

```
{
    "sidechain_name":"liquidjungl3",
    "mainnet_account":"dappservices",
    "chain_account":"testdappxxxx"
}
```

#### `eosio-chains/${CHAIN_ACCOUNT}.json`

`/zeus_boxes/liquidx/models/eosio-chains/${CHAIN_ACCOUNT}.json` - this maps the chain’s configuration details

* `dsp_port` - port DSP gateway runs on
* `webhook_dapp_port` - webhook port
* `nodeos_host` - nodeos host address
* `nodeos_port` - nodeos port
* `secured` - bool true/false for http/https for the nodeos address
* `nodeos_state_history_port` - port for nodeos state history websocket
* `nodeos_p2p_port` - nodeos peer 2 peer port
* `nodeos_endpoint` - full nodeos endpoint
* `demux_port` - demux port
* `name` - name of the chain account
* `local` - bool whether chain is local or not

{% tabs %}
{% tab title="Example" %}

```
{
    "dsp_port":13016,
    "webhook_dapp_port": 8813,
    "nodeos_host":"localhost",
    "nodeos_port":2424,
    "secured":false,
    "nodeos_state_history_port":12341,
    "nodeos_p2p_port":12451,
    "nodeos_endpoint":"http://localhost:2424",
    "demux_port":1232,
    "name":"CHAIN_ACCOUNT_HERE",
    "local":true
}
```

{% endtab %}

{% tab title="Jungle3" %}

```
{
    "dsp_port":3117,
    "webhook_dapp_port": 8813,
    "nodeos_host":"localhost",
    "nodeos_port":2424,
    "secured":false,
    "nodeos_state_history_port":12341,
    "nodeos_p2p_port":12451,
    "nodeos_endpoint":"http://localhost:2424",
    "demux_port":1232,
    "name":"liquidjungl3",
    "local":true
}
```

{% endtab %}
{% endtabs %}

#### Remove files:

Removing the following if they exist:

```bash
rm ./zeus_boxes/liquidx/models/liquidx-mappings/test1.dappservices.json
rm ./zeus_boxes/liquidx/models/liquidx-mappings/test1.provider1.json
rm ./zeus_boxes/liquidx/models/liquidx-mappings/test1.provider2.json
rm ./zeus_boxes/liquidx/models/eosio-chains/test1.json
```

#### Compile Contract Again with new files

```bash
export SIDE_CHAIN_NAME=liquidjungl3
zeus compile --sidechain $SIDE_CHAIN_NAME
```

{% hint style="info" %}
Jungle3 sidechain name: [liquidjungl3](https://kylin.bloks.io/account/liquidjungl3)
{% endhint %}

In order for the compiler to know which network the contract intends to be deployed on the `--sidechain` flag must be passed to `zeus compile --sidechain $SIDE_CHAIN_NAME`.

{% hint style="info" %}
Ensure that you add `@eosio.code` to the active permission level of the account. This can be done with the `--add-code` flag on the `cleos set account permission` command.
{% endhint %}

{% hint style="info" %}
The side chain name is the account on the EOS mainnet that has registered the chain. You may find what this contract is by asking a DSP, a BP, or the chain team itself.
{% endhint %}

#### dappservices config file

Now let's see why we did all of that, in the `./contracts/eos/dappservices/dappservices.config.hpp` we see:

```bash
#define DAPPSERVICEX_CONTRACT_TESTDAPPXXXX "liquidjungl3"_n

#define DAPPSERVICESA_CONTRACT "dappservices"_n

#ifdef LIQUIDX

#define DAPPSERVICES_CONTRACT DAPPSERVICEX_CONTRACT_TESTDAPPXXXX

#else

#define DAPPSERVICES_CONTRACT DAPPSERVICESA_CONTRACT

#endif
```

{% hint style="warning" %}
If you see `_TEST1` at all above, something is wrong and likely you need to remove the files suggested above.
{% endhint %}

#### Set Contract

```bash
cd zeus_boxes/contracts/eos
export EOS_ENDPOINT=
export ACCOUNT=
cleos -u $EOS_ENDPOINT set contract $ACCOUNT $MY_CONTRACT_NAME
```
