Skip to content

Commit f118fd3

Browse files
committed
Init README
1 parent c6460a5 commit f118fd3

File tree

2 files changed

+76
-5
lines changed

2 files changed

+76
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Running this Code Example
2+
3+
## Prerequisites
4+
5+
You'll need to have the contract address for a deployed instance of the [allow-list contract](./stellar-contracts/contracts/allow-list/src/lib.rs). Additionally, the `init` function on the contract should be called with the Stellar account you'd like to use as the admin of the contract (being an admin allows adding new address to the allow list).
6+
7+
### Deploying the Contract to Stellar Testnet
8+
9+
1. Follow [this setup guide](https://developers.stellar.org/docs/smart-contracts/getting-started/setup#install-the-target) to setup the `soroban` CLI
10+
2. Configure an identity to submit transaction to the testnet:
11+
```
12+
soroban keys generate --global alice --network testnet
13+
```
14+
3. Compile the smart contract:
15+
```
16+
soroban contract build
17+
```
18+
4. Deploy the contract
19+
```
20+
soroban contract deploy \
21+
--wasm target/wasm32-unknown-unknown/release/allow_list.wasm \
22+
--source alice \
23+
--network testnet
24+
```
25+
The output of this command will be the smart contract address we use to submit transactions to, make sure to copy it and save it for later (you're going to need to paste it in our [litAction.js](./nodejs/src/litAction.js) for the `ALLOW_LIST_CONTRACT_ADDRESS` `const`):
26+
```
27+
CBNUWSEPUI6DTKT7IYANIOYVFPWNVGELAUJY4HE4NQSEWW3I25BKWP6M
28+
```
29+
30+
### Initializing the Contract
31+
32+
You should call the `init` function the contract to set the admin for the contract:
33+
34+
```
35+
soroban contract invoke \
36+
--id CBNUWSEPUI6DTKT7IYANIOYVFPWNVGELAUJY4HE4NQSEWW3I25BKWP6M \
37+
--source alice \
38+
--network testnet \
39+
-- \
40+
init \
41+
--admin GCPQNAWI7DZ2OXVFP5ZWD7224HOOJVL6WRIMMEJ6PGS3ABMHFWC6ER6I
42+
```
43+
44+
The address passed as the `--admin` parameter will be the only addressed allow to add other address to the allow list.
45+
46+
### Verifying `admin` was Added to the Allow List
47+
48+
You can call the `is_allowed` function to verify the admin address we just initialized the contract with is in fact on the allow list:
49+
50+
```
51+
soroban contract invoke \
52+
--id CBNUWSEPUI6DTKT7IYANIOYVFPWNVGELAUJY4HE4NQSEWW3I25BKWP6M \
53+
--source alice \
54+
--network testnet \
55+
-- \
56+
id_allowed \
57+
--address GCPQNAWI7DZ2OXVFP5ZWD7224HOOJVL6WRIMMEJ6PGS3ABMHFWC6ER6I
58+
```
59+
60+
## Running the Code
61+
62+
Now that we have a Stellar smart contract deployed and initialized, follow these steps to run the code example:
63+
64+
1. `cd` into the `nodejs` directory
65+
2. Install the project dependencies with `yarn`
66+
3. `cp .env.example .env` and fill in the required ENVs:
67+
```
68+
STELLAR_SECRET=
69+
STELLAR_ACCOUNT_SEQUENCE_NUMBER=0
70+
ETHEREUM_PRIVATE_KEY=
71+
LIT_ACTION_IPFS_CID=
72+
LIT_PKP_PUBLIC_KEY=
73+
```
74+
4. In order to set the `LIT_ACTION_IPFS_CID` ENV, we'll need to build our Lit Action code and upload it to IPFS. To build it, run `yarn build:lit-action`. Then you can upload the resulting file found under `dist/litAction.js` to IPFS and get the CID
75+
- Before doing this, remember to replace the value for `ALLOW_LIST_CONTRACT_ADDRESS` in [litAction.js](./nodejs/src/litAction.js) to the address of the contract you deployed and initialized with your admin address
76+
5. Finally, run `yarn start` to execute the code found in [index.js](./nodejs/src/index.ts)

lit-access-control-conditions-stellar/nodejs/README.md

-5
This file was deleted.

0 commit comments

Comments
 (0)