This commit is contained in:
2026-04-05 00:43:23 +05:30
commit 8be37d3e92
425 changed files with 101853 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
# Copy this file to .env and fill values
CELO_RPC_URL=https://forno.celo-sepolia.celo-testnet.org
CONTRACT_ADDRESS=0xa520d207c91C0FE0e9cFe8D63AbE02fd18B2254e
PRIVATE_KEY=0xYOUR_PRIVATE_KEY_HERE
CUSD_SEPOLIA_ADDRESS=0x845D9D0B4Be004Dcbc17b11160B0C18abBD5FEBD
PORT=4000
BACKEND_URL=http://localhost:3001
BACKEND_URL=http://localhost:3001

5
dmtp/client_admin/.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
node_modules
# Keep environment variables out of version control
.env
/generated/prisma

View File

@@ -0,0 +1,32 @@
# client_admin
Small admin dashboard for creating tasks on the `TaskEscrow` contract.
## Setup
1. Copy `.env.example` to `.env` and fill in values (PRIVATE_KEY, CONTRACT_ADDRESS if different).
2. Install dependencies:
```powershell
cd client_admin
npm install
```
3. Run the server:
```powershell
npm start
```
4. Open dashboard: http://localhost:4000
## Endpoints
- GET `/` - dashboard UI
- POST `/api/create-task` - create task on blockchain. JSON body: `{ paymentAmount: "0.01", durationInDays: 7, workerAddress?: "0x..." }`
## Notes
- This server uses the ABI located at `../server/artifacts/contracts/TaskEscrow.sol/TaskEscrow.json`. Ensure the artifact exists (deploy the contract if necessary).
- The server signs transactions using `PRIVATE_KEY` in `.env`. Be careful with private keys.

953
dmtp/client_admin/package-lock.json generated Normal file
View File

@@ -0,0 +1,953 @@
{
"name": "client_admin",
"version": "0.1.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "client_admin",
"version": "0.1.0",
"dependencies": {
"body-parser": "^1.20.2",
"dotenv": "^17.2.3",
"ethers": "^6.0.0",
"express": "^4.18.2"
}
},
"node_modules/@adraffy/ens-normalize": {
"version": "1.10.1",
"resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.10.1.tgz",
"integrity": "sha512-96Z2IP3mYmF1Xg2cDm8f1gWGf/HUVedQ3FMifV4kG/PQ4yEP51xDtRAEfhVNt5f/uzpNkZHwWQuUcu6D6K+Ekw==",
"license": "MIT"
},
"node_modules/@noble/curves": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.2.0.tgz",
"integrity": "sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==",
"license": "MIT",
"dependencies": {
"@noble/hashes": "1.3.2"
},
"funding": {
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/@noble/hashes": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz",
"integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==",
"license": "MIT",
"engines": {
"node": ">= 16"
},
"funding": {
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/@types/node": {
"version": "22.7.5",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.5.tgz",
"integrity": "sha512-jML7s2NAzMWc//QSJ1a3prpk78cOPchGvXJsC3C6R6PSMoooztvRVQEz89gmBTBY1SPMaqo5teB4uNHPdetShQ==",
"license": "MIT",
"dependencies": {
"undici-types": "~6.19.2"
}
},
"node_modules/accepts": {
"version": "1.3.8",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
"integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
"license": "MIT",
"dependencies": {
"mime-types": "~2.1.34",
"negotiator": "0.6.3"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/aes-js": {
"version": "4.0.0-beta.5",
"resolved": "https://registry.npmjs.org/aes-js/-/aes-js-4.0.0-beta.5.tgz",
"integrity": "sha512-G965FqalsNyrPqgEGON7nIx1e/OVENSgiEIzyC63haUMuvNnwIgIjMs52hlTCKhkBny7A2ORNlfY9Zu+jmGk1Q==",
"license": "MIT"
},
"node_modules/array-flatten": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==",
"license": "MIT"
},
"node_modules/body-parser": {
"version": "1.20.3",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz",
"integrity": "sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==",
"license": "MIT",
"dependencies": {
"bytes": "3.1.2",
"content-type": "~1.0.5",
"debug": "2.6.9",
"depd": "2.0.0",
"destroy": "1.2.0",
"http-errors": "2.0.0",
"iconv-lite": "0.4.24",
"on-finished": "2.4.1",
"qs": "6.13.0",
"raw-body": "2.5.2",
"type-is": "~1.6.18",
"unpipe": "1.0.0"
},
"engines": {
"node": ">= 0.8",
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/bytes": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
"integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/call-bind-apply-helpers": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
"integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/call-bound": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz",
"integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.2",
"get-intrinsic": "^1.3.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/content-disposition": {
"version": "0.5.4",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
"integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
"license": "MIT",
"dependencies": {
"safe-buffer": "5.2.1"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/content-type": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
"integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie": {
"version": "0.7.1",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz",
"integrity": "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie-signature": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
"integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==",
"license": "MIT"
},
"node_modules/debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"license": "MIT",
"dependencies": {
"ms": "2.0.0"
}
},
"node_modules/depd": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
"integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/destroy": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
"integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==",
"license": "MIT",
"engines": {
"node": ">= 0.8",
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/dotenv": {
"version": "17.2.3",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.2.3.tgz",
"integrity": "sha512-JVUnt+DUIzu87TABbhPmNfVdBDt18BLOWjMUFJMSi/Qqg7NTYtabbvSNJGOJ7afbRuv9D/lngizHtP7QyLQ+9w==",
"license": "BSD-2-Clause",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://dotenvx.com"
}
},
"node_modules/dunder-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
"integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.1",
"es-errors": "^1.3.0",
"gopd": "^1.2.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
"integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",
"license": "MIT"
},
"node_modules/encodeurl": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
"integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/es-define-property": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-errors": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-object-atoms": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz",
"integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/escape-html": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
"integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==",
"license": "MIT"
},
"node_modules/etag": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
"integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/ethers": {
"version": "6.15.0",
"resolved": "https://registry.npmjs.org/ethers/-/ethers-6.15.0.tgz",
"integrity": "sha512-Kf/3ZW54L4UT0pZtsY/rf+EkBU7Qi5nnhonjUb8yTXcxH3cdcWrV2cRyk0Xk/4jK6OoHhxxZHriyhje20If2hQ==",
"funding": [
{
"type": "individual",
"url": "https://github.com/sponsors/ethers-io/"
},
{
"type": "individual",
"url": "https://www.buymeacoffee.com/ricmoo"
}
],
"license": "MIT",
"dependencies": {
"@adraffy/ens-normalize": "1.10.1",
"@noble/curves": "1.2.0",
"@noble/hashes": "1.3.2",
"@types/node": "22.7.5",
"aes-js": "4.0.0-beta.5",
"tslib": "2.7.0",
"ws": "8.17.1"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/express": {
"version": "4.21.2",
"resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz",
"integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==",
"license": "MIT",
"dependencies": {
"accepts": "~1.3.8",
"array-flatten": "1.1.1",
"body-parser": "1.20.3",
"content-disposition": "0.5.4",
"content-type": "~1.0.4",
"cookie": "0.7.1",
"cookie-signature": "1.0.6",
"debug": "2.6.9",
"depd": "2.0.0",
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"finalhandler": "1.3.1",
"fresh": "0.5.2",
"http-errors": "2.0.0",
"merge-descriptors": "1.0.3",
"methods": "~1.1.2",
"on-finished": "2.4.1",
"parseurl": "~1.3.3",
"path-to-regexp": "0.1.12",
"proxy-addr": "~2.0.7",
"qs": "6.13.0",
"range-parser": "~1.2.1",
"safe-buffer": "5.2.1",
"send": "0.19.0",
"serve-static": "1.16.2",
"setprototypeof": "1.2.0",
"statuses": "2.0.1",
"type-is": "~1.6.18",
"utils-merge": "1.0.1",
"vary": "~1.1.2"
},
"engines": {
"node": ">= 0.10.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/finalhandler": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.1.tgz",
"integrity": "sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ==",
"license": "MIT",
"dependencies": {
"debug": "2.6.9",
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"on-finished": "2.4.1",
"parseurl": "~1.3.3",
"statuses": "2.0.1",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/forwarded": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
"integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/fresh": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
"integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/function-bind": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-intrinsic": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
"integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.2",
"es-define-property": "^1.0.1",
"es-errors": "^1.3.0",
"es-object-atoms": "^1.1.1",
"function-bind": "^1.1.2",
"get-proto": "^1.0.1",
"gopd": "^1.2.0",
"has-symbols": "^1.1.0",
"hasown": "^2.0.2",
"math-intrinsics": "^1.1.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
"integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
"license": "MIT",
"dependencies": {
"dunder-proto": "^1.0.1",
"es-object-atoms": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/gopd": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has-symbols": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/hasown": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
"integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
"license": "MIT",
"dependencies": {
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/http-errors": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz",
"integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==",
"license": "MIT",
"dependencies": {
"depd": "2.0.0",
"inherits": "2.0.4",
"setprototypeof": "1.2.0",
"statuses": "2.0.1",
"toidentifier": "1.0.1"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/iconv-lite": {
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
"license": "MIT",
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"license": "ISC"
},
"node_modules/ipaddr.js": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
"license": "MIT",
"engines": {
"node": ">= 0.10"
}
},
"node_modules/math-intrinsics": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
"integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
"integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/merge-descriptors": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz",
"integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/methods": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
"integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
"license": "MIT",
"bin": {
"mime": "cli.js"
},
"engines": {
"node": ">=4"
}
},
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"license": "MIT",
"dependencies": {
"mime-db": "1.52.0"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
"license": "MIT"
},
"node_modules/negotiator": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
"integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/object-inspect": {
"version": "1.13.4",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
"integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/on-finished": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
"integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
"license": "MIT",
"dependencies": {
"ee-first": "1.1.1"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/parseurl": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
"integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/path-to-regexp": {
"version": "0.1.12",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz",
"integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==",
"license": "MIT"
},
"node_modules/proxy-addr": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
"integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
"license": "MIT",
"dependencies": {
"forwarded": "0.2.0",
"ipaddr.js": "1.9.1"
},
"engines": {
"node": ">= 0.10"
}
},
"node_modules/qs": {
"version": "6.13.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz",
"integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==",
"license": "BSD-3-Clause",
"dependencies": {
"side-channel": "^1.0.6"
},
"engines": {
"node": ">=0.6"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/range-parser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
"integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/raw-body": {
"version": "2.5.2",
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz",
"integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==",
"license": "MIT",
"dependencies": {
"bytes": "3.1.2",
"http-errors": "2.0.0",
"iconv-lite": "0.4.24",
"unpipe": "1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "MIT"
},
"node_modules/safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"license": "MIT"
},
"node_modules/send": {
"version": "0.19.0",
"resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz",
"integrity": "sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==",
"license": "MIT",
"dependencies": {
"debug": "2.6.9",
"depd": "2.0.0",
"destroy": "1.2.0",
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"fresh": "0.5.2",
"http-errors": "2.0.0",
"mime": "1.6.0",
"ms": "2.1.3",
"on-finished": "2.4.1",
"range-parser": "~1.2.1",
"statuses": "2.0.1"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/send/node_modules/encodeurl": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
"integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/send/node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
"license": "MIT"
},
"node_modules/serve-static": {
"version": "1.16.2",
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.2.tgz",
"integrity": "sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==",
"license": "MIT",
"dependencies": {
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"parseurl": "~1.3.3",
"send": "0.19.0"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/setprototypeof": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==",
"license": "ISC"
},
"node_modules/side-channel": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz",
"integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"object-inspect": "^1.13.3",
"side-channel-list": "^1.0.0",
"side-channel-map": "^1.0.1",
"side-channel-weakmap": "^1.0.2"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-list": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz",
"integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"object-inspect": "^1.13.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-map": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz",
"integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==",
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.5",
"object-inspect": "^1.13.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-weakmap": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz",
"integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==",
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.5",
"object-inspect": "^1.13.3",
"side-channel-map": "^1.0.1"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/statuses": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
"integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/toidentifier": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
"integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
"license": "MIT",
"engines": {
"node": ">=0.6"
}
},
"node_modules/tslib": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz",
"integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==",
"license": "0BSD"
},
"node_modules/type-is": {
"version": "1.6.18",
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
"integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
"license": "MIT",
"dependencies": {
"media-typer": "0.3.0",
"mime-types": "~2.1.24"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/undici-types": {
"version": "6.19.8",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz",
"integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==",
"license": "MIT"
},
"node_modules/unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
"integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/utils-merge": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
"integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
"license": "MIT",
"engines": {
"node": ">= 0.4.0"
}
},
"node_modules/vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
"integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/ws": {
"version": "8.17.1",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz",
"integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==",
"license": "MIT",
"engines": {
"node": ">=10.0.0"
},
"peerDependencies": {
"bufferutil": "^4.0.1",
"utf-8-validate": ">=5.0.2"
},
"peerDependenciesMeta": {
"bufferutil": {
"optional": true
},
"utf-8-validate": {
"optional": true
}
}
}
}
}

View File

@@ -0,0 +1,14 @@
{
"name": "client_admin",
"version": "0.1.0",
"type": "module",
"scripts": {
"start": "node src/server.js"
},
"dependencies": {
"body-parser": "^1.20.2",
"dotenv": "^17.2.3",
"ethers": "^6.0.0",
"express": "^4.18.2"
}
}

View File

@@ -0,0 +1,449 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>Admin Dashboard - Create Task</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #0f0f0f 0%, #1a1a1a 100%);
min-height: 100vh;
padding: 2rem;
color: #fff;
}
.container {
max-width: 600px;
margin: 0 auto;
}
.header {
text-align: center;
color: #ff9500;
margin-bottom: 2rem;
}
.header h1 {
font-size: 2.5rem;
margin-bottom: 0.5rem;
font-weight: 700;
text-shadow: 0 0 20px rgba(255, 149, 0, 0.3);
}
.header p {
font-size: 1.1rem;
opacity: 0.8;
color: #ccc;
}
.card {
background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
border-radius: 12px;
padding: 2rem;
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5),
0 0 30px rgba(255, 149, 0, 0.1);
border: 1px solid rgba(255, 149, 0, 0.15);
}
.form-group {
margin-bottom: 1.5rem;
}
.form-group:last-of-type {
margin-bottom: 0;
}
label {
display: block;
font-weight: 600;
color: #ff9500;
margin-bottom: 0.5rem;
font-size: 0.95rem;
text-transform: uppercase;
letter-spacing: 0.5px;
}
input,
select,
textarea {
width: 100%;
padding: 0.75rem 1rem;
border: 2px solid rgba(255, 149, 0, 0.2);
border-radius: 8px;
font-size: 1rem;
font-family: inherit;
transition: all 0.3s ease;
background: rgba(0, 0, 0, 0.3);
color: #fff;
}
input::placeholder,
select::placeholder,
textarea::placeholder {
color: rgba(255, 255, 255, 0.4);
}
input:focus,
select:focus,
textarea:focus {
outline: none;
border-color: #ff9500;
box-shadow: 0 0 0 3px rgba(255, 149, 0, 0.2),
inset 0 0 10px rgba(255, 149, 0, 0.05);
background: rgba(0, 0, 0, 0.5);
}
.form-row {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1rem;
}
.form-row .form-group {
margin-bottom: 0;
}
textarea {
resize: vertical;
min-height: 100px;
}
button {
width: 100%;
padding: 0.875rem 1.5rem;
background: linear-gradient(135deg, #ff9500 0%, #ff7700 100%);
color: #000;
border: none;
border-radius: 8px;
font-size: 1rem;
font-weight: 700;
cursor: pointer;
transition: all 0.3s ease;
margin-top: 1.5rem;
text-transform: uppercase;
letter-spacing: 1px;
box-shadow: 0 4px 15px rgba(255, 149, 0, 0.3);
}
button:hover {
transform: translateY(-2px);
box-shadow: 0 8px 25px rgba(255, 149, 0, 0.5);
background: linear-gradient(135deg, #ffaa00 0%, #ff8800 100%);
}
button:active {
transform: translateY(0);
}
button:disabled {
opacity: 0.5;
cursor: not-allowed;
transform: none;
box-shadow: 0 4px 15px rgba(255, 149, 0, 0.1);
}
.result {
margin-top: 1.5rem;
padding: 1rem;
border-radius: 8px;
border-left: 4px solid #ff9500;
background: rgba(255, 149, 0, 0.1);
color: #fff;
display: none;
}
.result.success {
border-left-color: #10b981;
background: rgba(16, 185, 129, 0.1);
}
.result.error {
border-left-color: #ef4444;
background: rgba(239, 68, 68, 0.1);
}
.result strong {
display: block;
margin-bottom: 0.5rem;
font-size: 1.1rem;
color: #ff9500;
}
.result.success strong {
color: #10b981;
}
.result.error strong {
color: #ef4444;
}
.result p {
margin: 0.25rem 0;
word-break: break-all;
font-size: 0.9rem;
font-family: "Courier New", monospace;
color: #ccc;
}
.loading {
display: inline-block;
width: 12px;
height: 12px;
border: 2px solid #ff9500;
border-top-color: transparent;
border-radius: 50%;
animation: spin 0.8s linear infinite;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>✨ Task Admin</h1>
<p>Create tasks on blockchain</p>
</div>
<div class="card">
<div style="background: rgba(255, 149, 0, 0.05); border: 1px solid rgba(255, 149, 0, 0.2); border-radius: 8px; padding: 1rem; margin-bottom: 1.5rem; font-size: 0.9rem;">
<div style="margin-bottom: 0.5rem;"><strong>Wallet Info</strong></div>
<div id="walletInfo" style="color: #ccc; font-family: monospace; line-height: 1.5;">Loading...</div>
<button id="approveBtn" style="margin-top: 0.75rem; padding: 0.5rem; background: rgba(255, 149, 0, 0.2); color: #ff9500; font-size: 0.85rem;">Approve cUSD</button>
</div>
<label for="taskName">Task Name</label>
<input
id="taskName"
type="text"
placeholder="e.g., Image Classification Task"
value=""
/>
</div>
<div class="form-group">
<label for="taskType">Task Type</label>
<select id="taskType">
<option value="image-classification">Image Classification</option>
<option value="text-labeling">Text Labeling</option>
<option value="data-entry">Data Entry</option>
<option value="content-moderation">Content Moderation</option>
<option value="transcription">Transcription</option>
<option value="other">Other</option>
</select>
</div>
<div class="form-group">
<label for="description">Task Description</label>
<textarea
id="description"
placeholder="Describe what needs to be done..."
></textarea>
</div>
<div class="form-row">
<div class="form-group">
<label for="paymentAmount">Payment (cUSD)</label>
<input
id="paymentAmount"
type="number"
placeholder="0.01"
value="0.01"
step="0.001"
min="0"
/>
</div>
<div class="form-group">
<label for="duration">Duration (days)</label>
<input
id="duration"
type="number"
placeholder="7"
value="7"
min="1"
max="365"
/>
</div>
</div>
<div class="form-group">
<label for="worker">Worker Address (optional)</label>
<input id="worker" type="text" placeholder="0x..." />
</div>
<button id="submit">Create Task on Blockchain</button>
<div id="result" class="result"></div>
</div>
<script>
// Load wallet info on page load
async function loadWalletInfo() {
try {
const resp = await fetch("/api/wallet-info");
if (!resp.ok) {
console.error("Wallet info response status:", resp.status);
throw new Error(`HTTP ${resp.status}`);
}
const data = await resp.json();
if (data.error) {
console.error("Wallet info error:", data.error);
document.getElementById("walletInfo").textContent = "Error: " + data.error;
return;
}
const info = document.getElementById("walletInfo");
info.innerHTML = `
<div>Address: ${data.walletAddress}</div>
<div>CELO: ${parseFloat(data.celoBalance).toFixed(4)}</div>
<div>cUSD: ${parseFloat(data.cusdBalance).toFixed(2)}</div>
<div>Allowance: ${parseFloat(data.contractAllowance).toFixed(2)}</div>
`;
} catch (err) {
console.error("loadWalletInfo error:", err);
document.getElementById("walletInfo").textContent = "Error loading wallet info: " + err.message;
}
}
// Approve button
document.getElementById("approveBtn").addEventListener("click", async () => {
const btn = document.getElementById("approveBtn");
btn.disabled = true;
btn.textContent = "Approving...";
try {
const resp = await fetch("/api/approve-cusd", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ amount: "1000000" }),
});
const data = await resp.json();
if (data.error) {
alert("Approval failed: " + data.error);
} else if (data.success && data.txHash) {
alert("Approved! Tx: " + data.txHash.substring(0, 20) + "...");
await new Promise(r => setTimeout(r, 2000));
await loadWalletInfo();
} else {
alert("Approval response: " + JSON.stringify(data));
}
} catch (err) {
alert("Error: " + err.message);
console.error("Approve error:", err);
} finally {
btn.disabled = false;
btn.textContent = "Approve cUSD";
}
});
const submit = document.getElementById("submit");
const result = document.getElementById("result");
function showResult(message, isSuccess = true, details = null) {
result.style.display = "block";
result.className = isSuccess ? "result success" : "result error";
result.innerHTML = `<strong>${
isSuccess ? "✓ Success" : "✗ Error"
}</strong><p>${message}</p>`;
if (details) {
result.innerHTML += `<p style="margin-top: 0.5rem; opacity: 0.8;">${details}</p>`;
}
}
submit.addEventListener("click", async () => {
const taskName = document.getElementById("taskName").value;
const taskType = document.getElementById("taskType").value;
const description = document.getElementById("description").value;
const paymentAmount = document.getElementById("paymentAmount").value;
const durationInDays = document.getElementById("duration").value;
const worker = document.getElementById("worker").value;
if (!taskName || !paymentAmount || !durationInDays) {
showResult(
"Please fill in task name, payment, and duration",
false
);
return;
}
result.style.display = "block";
result.className = "result";
result.innerHTML =
'<span class="loading"></span> Sending transaction...';
submit.disabled = true;
const body = {
taskName,
taskType,
description,
paymentAmount: parseFloat(paymentAmount),
durationInDays: parseInt(durationInDays),
workerAddress: worker || undefined,
};
try {
const resp = await fetch("/api/create-task", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body),
});
const json = await resp.json();
if (json.error) {
showResult(json.error, false, json.details);
} else {
const txInfo = json.txHash ? `Tx: ${json.txHash.substring(0, 20)}...<br/>` : "No tx hash";
showResult(
`Task created on blockchain!`,
true,
`${txInfo}TaskId: ${json.taskId || "unknown"}<br/>Syncing to database...`
);
// Now sync to backend database with complete metadata
try {
const syncResp = await fetch("/api/sync-task", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
taskId: json.taskId,
txHash: json.txHash,
metadata: {
name: taskName,
type: taskType,
description,
paymentAmount: parseFloat(paymentAmount),
durationInDays: parseInt(durationInDays),
maxSubmissions: 10,
},
}),
});
const syncJson = await syncResp.json();
console.log("Sync response:", syncJson);
if (syncResp.ok && syncJson.success) {
showResult(
`Task created and synced!`,
true,
`BlockchainId: ${json.taskId}<br/>DB ID: ${syncJson.data?.task?.id || "synced"}<br/>Status: Live in database`
);
} else {
const errorMsg = syncJson.error?.message || syncJson.error || "Unknown error";
showResult(
`Task created on blockchain but sync failed`,
false,
`BlockchainId: ${json.taskId}<br/>Error: ${errorMsg}`
);
}
} catch (syncErr) {
showResult(
`Task created on blockchain but sync failed`,
false,
`BlockchainId: ${json.taskId}<br/>Error: ${syncErr.message}`
);
}
// Reset form
document.getElementById("taskName").value = "";
document.getElementById("description").value = "";
document.getElementById("paymentAmount").value = "0.01";
document.getElementById("duration").value = "7";
document.getElementById("worker").value = "";
await new Promise(r => setTimeout(r, 2000));
await loadWalletInfo();
}
} catch (err) {
showResult("Request failed: " + err.message, false);
} finally {
submit.disabled = false;
}
});
// Load wallet info when page loads
loadWalletInfo();
// Refresh every 30 seconds
setInterval(loadWalletInfo, 30000);
</script>
</div>
</body>
</html>

View File

@@ -0,0 +1,354 @@
import express from "express";
import bodyParser from "body-parser";
import { readFileSync } from "fs";
import { join } from "path";
import dotenv from "dotenv";
import { ethers } from "ethers";
dotenv.config();
const app = express();
app.use(bodyParser.json());
app.use(express.static(join(process.cwd(), "src", "public")));
const RPC_URL =
process.env.CELO_RPC_URL || "https://forno.celo-sepolia.celo-testnet.org";
const CONTRACT_ADDRESS = process.env.CONTRACT_ADDRESS;
const PRIVATE_KEY = process.env.PRIVATE_KEY;
if (!CONTRACT_ADDRESS) {
console.error("CONTRACT_ADDRESS not set in .env");
}
if (!PRIVATE_KEY) {
console.error("PRIVATE_KEY not set in .env");
}
// Load ABI from artifacts folder (reuse server artifact)
const artifactPath = join(
process.cwd(),
"..",
"server",
"artifacts",
"contracts",
"TaskEscrow.sol",
"TaskEscrow.json"
);
let TaskEscrowABI;
try {
TaskEscrowABI = JSON.parse(readFileSync(artifactPath, "utf8")).abi;
} catch (err) {
console.error(
"Failed to load TaskEscrow ABI from artifacts. Make sure path exists:",
artifactPath
);
process.exit(1);
}
const provider = new ethers.JsonRpcProvider(RPC_URL);
const wallet = new ethers.Wallet(PRIVATE_KEY || ethers.ZeroHash, provider);
const contract = new ethers.Contract(CONTRACT_ADDRESS, TaskEscrowABI, wallet);
// Simple health endpoint
app.get("/api/health", (req, res) => {
res.json({ status: "ok", contract: CONTRACT_ADDRESS });
});
// Check wallet balance and allowance
app.get("/api/wallet-info", async (req, res) => {
try {
console.log("Fetching wallet info...");
const balance = await provider.getBalance(wallet.address);
console.log("CELO balance:", ethers.formatEther(balance));
// Get cUSD contract
const cusdAddress = process.env.CUSD_SEPOLIA_ADDRESS;
const cusdABI = [
"function balanceOf(address) view returns (uint256)",
"function allowance(address owner, address spender) view returns (uint256)",
];
let cusdBalance = BigInt(0);
let allowance = BigInt(0);
if (cusdAddress) {
try {
console.log("Fetching cUSD info from:", cusdAddress);
const cusd = new ethers.Contract(cusdAddress, cusdABI, provider);
cusdBalance = await cusd.balanceOf(wallet.address);
allowance = await cusd.allowance(wallet.address, CONTRACT_ADDRESS);
console.log("cUSD balance:", ethers.formatEther(cusdBalance));
console.log("Allowance:", ethers.formatEther(allowance));
} catch (err) {
console.error("Error fetching cUSD info:", err.message);
// Continue with zero values
}
}
const response = {
walletAddress: wallet.address,
celoBalance: ethers.formatEther(balance),
cusdBalance: ethers.formatEther(cusdBalance),
contractAllowance: ethers.formatEther(allowance),
};
console.log("Sending wallet info:", response);
res.json(response);
} catch (error) {
console.error("Wallet info error:", error.message);
res.status(500).json({ error: error.message });
}
});
// Approve cUSD spending
app.post("/api/approve-cusd", async (req, res) => {
try {
const { amount } = req.body;
const approveAmount = ethers.parseEther(String(amount || "1000000")); // Default to 1M cUSD
const cusdAddress = process.env.CUSD_SEPOLIA_ADDRESS;
if (!cusdAddress) {
return res
.status(400)
.json({ error: "CUSD_SEPOLIA_ADDRESS not configured" });
}
const cusdABI = [
"function approve(address spender, uint256 amount) returns (bool)",
];
const cusd = new ethers.Contract(cusdAddress, cusdABI, wallet);
console.log(
`Approving ${ethers.formatEther(
approveAmount
)} cUSD for contract ${CONTRACT_ADDRESS}`
);
const tx = await cusd.approve(CONTRACT_ADDRESS, approveAmount);
console.log("Approve tx sent:", tx.hash);
const receipt = await tx.wait();
res.json({
success: true,
txHash: receipt.transactionHash,
approvedAmount: ethers.formatEther(approveAmount),
});
} catch (error) {
console.error("Approval error:", error);
res.status(500).json({
error: error.message,
details: error.reason || error.code,
});
}
});
// Create task endpoint
app.post("/api/create-task", async (req, res) => {
try {
const {
taskName,
taskType,
description,
paymentAmount,
durationInDays,
workerAddress,
} = req.body;
if (!paymentAmount || !durationInDays) {
return res.status(400).json({
error: "paymentAmount and durationInDays are required",
});
}
// Log task metadata (in production, you'd store this in DB)
console.log(`Creating task:`, {
name: taskName || "unnamed",
type: taskType || "unknown",
description: description || "no description",
payment: paymentAmount,
duration: durationInDays,
worker: workerAddress || "unassigned",
});
// Convert paymentAmount (cUSD) to wei - must be a string
let amountWei;
try {
amountWei = ethers.parseEther(String(paymentAmount));
console.log(`Amount in wei: ${amountWei.toString()}`);
} catch (err) {
console.error("Failed to parse amount:", err.message);
return res.status(400).json({
error: "Invalid payment amount",
details: err.message,
});
}
console.log(`About to call createTask on contract ${CONTRACT_ADDRESS}`);
// Check wallet balance first
const balance = await provider.getBalance(wallet.address);
console.log("Wallet CELO balance:", ethers.formatEther(balance));
if (balance < ethers.parseEther("0.001")) {
return res.status(400).json({
error: "Insufficient CELO balance for gas",
details: `Balance: ${ethers.formatEther(
balance
)} CELO. Need at least 0.001 CELO`,
});
}
const tx = await contract.createTask(amountWei, Number(durationInDays));
console.log("Transaction sent:", tx.hash);
const receipt = await tx.wait();
if (!receipt) {
console.error("Transaction receipt is null/undefined!");
return res.status(500).json({
error: "Transaction failed - no receipt returned",
details:
"The transaction may have failed. Check if you have sufficient cUSD allowance.",
txHash: tx.hash,
});
}
console.log("Transaction confirmed:", {
hash: receipt.hash,
transactionHash: receipt.transactionHash,
blockNumber: receipt.blockNumber,
status: receipt.status,
logsCount: receipt.logs.length,
});
// Try to parse event TaskCreated
let taskId = null;
console.log("Parsing logs...");
for (const log of receipt.logs) {
try {
const parsed = contract.interface.parseLog(log);
console.log("Parsed log:", parsed.name);
if (parsed.name === "TaskCreated") {
taskId = parsed.args[0].toString();
console.log("Found TaskCreated event with taskId:", taskId);
break;
}
} catch (e) {
console.log("Could not parse log:", e.message);
}
}
const finalTxHash = receipt.hash || receipt.transactionHash || tx.hash;
console.log("Final txHash:", finalTxHash);
console.log("Task creation complete. TaskId:", taskId);
return res.json({
success: true,
txHash: finalTxHash,
taskId,
metadata: {
name: taskName,
type: taskType,
description,
},
});
} catch (error) {
console.error("Create task error:", error);
// Provide helpful error messages
let errorMsg = String(error);
let details = error.reason || error.message || "";
if (error.code === "INSUFFICIENT_FUNDS") {
errorMsg = "Insufficient balance to create task";
details =
"The wallet doesn't have enough CELO to pay for the transaction";
} else if (error.code === "CALL_EXCEPTION") {
errorMsg = "Contract call failed";
details = error.reason || "Check that the contract address is correct";
} else if (errorMsg.includes("Insufficient allowance")) {
errorMsg = "Insufficient cUSD allowance";
details = "Please approve the contract to spend cUSD first";
}
return res.status(500).json({
error: errorMsg,
details: details,
code: error.code,
});
}
});
// Sync task to database (backend server)
app.post("/api/sync-task", async (req, res) => {
try {
const { taskId, txHash, metadata } = req.body;
if (!taskId || !txHash) {
return res.status(400).json({
error: "taskId and txHash are required",
});
}
const backendUrl = process.env.BACKEND_URL || "http://localhost:3001";
console.log(`Syncing task ${taskId} to backend: ${backendUrl}`);
const syncPayload = {
contractTaskId: parseInt(taskId),
transactionHash: txHash,
paymentAmount: parseFloat(metadata?.paymentAmount || "0"),
taskName: metadata?.name || "Unnamed Task",
taskType: metadata?.type || "text-labeling",
description: metadata?.description || "Task created via admin dashboard",
maxSubmissions: metadata?.maxSubmissions || 10,
durationInDays: metadata?.durationInDays || 7,
verificationCriteria: {
transactionHash: txHash,
blockchainCreated: true,
},
};
console.log("Sync payload:", syncPayload);
const syncResponse = await fetch(`${backendUrl}/api/v1/tasks/sync`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(syncPayload),
});
const syncData = await syncResponse.text();
console.log(`Sync response status: ${syncResponse.status}`);
console.log("Sync response body:", syncData);
if (!syncResponse.ok) {
console.error("Sync error response:", syncData);
return res.status(500).json({
error: "Failed to sync task to backend",
details: syncData,
});
}
const syncedTask = JSON.parse(syncData);
console.log("Task synced successfully:", syncedTask);
res.json({
success: true,
message: "Task synced to backend database",
data: syncedTask,
});
} catch (error) {
console.error("Sync task error:", error);
res.status(500).json({
error: error.message,
details: "Failed to sync task to backend",
});
}
});
// Serve dashboard page
app.get("/", (req, res) => {
res.sendFile(join(process.cwd(), "src", "public", "index.html"));
});
const PORT = process.env.PORT || 4000;
app.listen(PORT, () => {
console.log(`Admin dashboard listening on http://localhost:${PORT}`);
});