The example project included in this repository serves as a working example of how to integrate sponsored transactions with smart contracts on the Concordium blockchain. The project has a frontend and a backend.
Clone the root repo with the following command:
git clone --recurse-submodules [email protected]:Concordium/concordium-dapp-examples.git
or
git clone --recurse-submodules https://github.com/Concordium/concordium-dapp-examples.git
To set up the project locally, complete the steps in the README.md
file in the sponsoredTransactions/frontend
folder and then complete the steps in the README.md
file in the sponsoredTransactions/backend
folder.
Alternatively, follow the steps to deploy the docker container below. This docker container will set up the frontend as well as the backend.
Add your ACCOUNT_KEY_FILE
to the repository's root folder and run the dockerfile from the repository's root folder with the command:
docker build -t sponsored_transactions -f sponsoredTransactions/Dockerfile .
The image can then be run with:
docker run -p 8080:8080 --mount type=bind,source="$(pwd)"/<ACCOUNT_KEY_FILE>,target=/KEY_FILE,readonly sponsored_transactions
e.g.
docker run -p 8080:8080 --mount type=bind,source="$(pwd)"/3PXwJYYPf6fyVb4GJquxSZU8puxrHfzc4XogdMVot8MUQK53tW.export,target=/KEY_FILE,readonly sponsored_transactions
Note: To get your ACCOUNT_KEY_FILE
(the 3PXwJYYPf6fyVb4GJquxSZU8puxrHfzc4XogdMVot8MUQK53tW.export
file), export it from the Concordium Browser Wallet for Web.
This account should be only used for this service. No transactions should be sent from the account by any other means to ensure the account nonce is tracked
correctly in the service (e.g. don't use the 3PXwJYYPf6fyVb4GJquxSZU8puxrHfzc4XogdMVot8MUQK53tW
account in the browser wallet to send transactions via the front end).
See the docker file to explore the environment variables that can set.
Note: Use the same smart contract index for the frontend and backend. In other words, use the smart contract index from the ./frontend/package.json
file in the dockerfile.
You can find an associated tutorial on the developer documentation.