Skip to content

Commit

Permalink
Initial sponsored transaction enabled auction
Browse files Browse the repository at this point in the history
  • Loading branch information
DOBEN committed Nov 29, 2023
1 parent 016a08f commit 1bb512b
Show file tree
Hide file tree
Showing 68 changed files with 15,139 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ node_modules
.env.development.local
.env.test.local
.env.production.local
.yarn/*
/**/.yarn/*

npm-debug.log*
yarn-debug.log*
Expand All @@ -27,4 +27,4 @@ yarn-error.log*
target
dist
gallery/public
.eslintcache
.eslintcache
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ The following examples are available.

- [gallery](./gallery/) demonstrates a gallery which requires the user to authorize using ID proofs from the browser wallet.

- [sponsoredTransactions](./sponsoredTransactions/) demonstrates how a user (without holding CCD in the wallet) can sign a message with the browser wallet or mobile wallet through wallet connect and submit the signature to a backend. The backend pays for the transaction fee and submits the sponsored transaction on behalf of the user to the chain.
- [sponsoredTransactionsBasic](./sponsoredTransactionsBasic/) demonstrates how a user (without holding CCD in the wallet) can sign a message with the browser wallet or mobile wallet through wallet connect and submit the signature to a backend. The backend pays for the transaction fee and submits the sponsored transaction on behalf of the user to the chain.

- [sponsoredTransactionsAuction](./sponsoredTransactionsAuction/) demonstrates how to use a sponsored-transaction-enabled token as a payment method in an auction contract so that the user does not have to hold CCD in their wallet. The user signs a bidding message with the browser wallet or mobile wallet through wallet connect and submit the signature to a backend. The backend pays for the transaction fee and submits the sponsored transaction on behalf of the user to the chain.

- [simple age verification](./simpleAgeVerification/) demonstrates in a simple use case of verifiying the users age with the browser wallet.

Expand Down
File renamed without changes.
55 changes: 55 additions & 0 deletions sponsoredTransactionsAuction/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Sponsored Transactions Auction Web Application

This repository includes a dApp example of an auction. Users can bid for the items in the auction contract by using a sponsored-transaction-enabled token as a payment method (no CCD required in the user's wallet). The project has a front end and a back end.

Clone the root repo with the following command:

```shell
git clone --recurse-submodules [email protected]:Concordium/concordium-dapp-examples.git
```

or
```shell
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.

## Run as docker

Add your `ACCOUNT_KEY_FILE` to the repository's root folder and run the dockerfile from the repository's root folder with the command:
```shell
docker build -t sponsored_transactions -f sponsoredTransactions/Dockerfile .
```


The image can then be run with:
```shell
docker run -p 8080:8080 --mount type=bind,source="$(pwd)"/<ACCOUNT_KEY_FILE>,target=/KEY_FILE,readonly sponsored_transactions
```

e.g.

```shell
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.

<img src="./backend/pic/pic1.png" width="200" />
<img src="./backend/pic/pic2.png" width="200" />
<img src="./backend/pic/pic3.png" width="200" />

See the [docker file](./Dockerfile) 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.



## Explore the tutorial

You can find an associated tutorial on the [developer documentation](./https://developer.concordium.software/en/mainnet/smart-contracts/tutorials/index.html).


File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
35 changes: 35 additions & 0 deletions sponsoredTransactionsBasic/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
ARG node_base_image=node:16-slim
ARG rust_base_image=rust:1.65

FROM ${node_base_image} AS frontend

WORKDIR /app
COPY ./sponsoredTransactions/frontend ./

RUN yarn && yarn cache clean
RUN yarn build

FROM ${rust_base_image} AS backend

WORKDIR /backend
COPY ./deps/concordium-rust-sdk /deps/concordium-rust-sdk
COPY ./sponsoredTransactions/backend ./

RUN cargo build --release

FROM ubuntu:22.04
WORKDIR /build

ENV PORT=8080
ENV NODE=http://node.testnet.concordium.com:20000
ENV LOG_LEVEL=info
ENV SMART_CONTRACT_INDEX=6372

ENV ACCOUNT_KEY_FILE=/KEY_FILE

COPY --from=backend ./backend/target/release/sponsored-transaction-backend ./main
COPY --from=frontend ./app/dist ./public

RUN chmod +x ./main

CMD ./main --node "${NODE}" --port "${PORT}" --account "${ACCOUNT_KEY_FILE}" --smart-contract-index "${SMART_CONTRACT_INDEX}" --log-level "${LOG_LEVEL}" --public-folder public
File renamed without changes.
9 changes: 9 additions & 0 deletions sponsoredTransactionsBasic/backend/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Unreleased changes

## 2.0.0

- Use `AccountSignatures` type for the input parameter to the `permit` function. The sponsored transaction smart contract uses the `check_account_signature` host function with the `AccountSignatures` type as input parameter to verify signatures in the smart contract now.

## 1.0.0

- Initial sponsored transaction back end.
Loading

0 comments on commit 1bb512b

Please sign in to comment.