An implementation for managing housing similar to how Air-BNB works.
- Each owner of the house generates a contract for their own house or unit.
- Each house or unit, get's a contract.
- A user/renter can then book to rent the house at a specific date
- The user/renter should verify ownership at the place before entering.
- Currency used is NEAR.
- Angular cli, for running tests
- node >=12 with npm.
- Rust and cargo, for compiling the contracts
- Near cli (install via
npm install --global near-cli
)
-
near login
Login with the testnet account used for deploying and doing tests
-
npm install
Installs the dependencies required to run tests and following steps
-
npm run setup
Sets up the contract name from env file in ./neardev/dev-account.env which should look like this:
MAIN_CONTRACT_ADDRESS = "hse.borwe2.testnet";
This will be the contract address to be used for deploying the contract after building, make sure the file exists, or it would default to
hse.borwe2.testnet
also make sure the MAIN_CONTRACT_ADDRESS, contains an actual existing address in testnet, otherwise it would fail. when it comes to deploying the contract.Make sure that the sub address matches your account that you used in previous command of
near login
, eg: if account was borwe2.testnet, then the main account address will be hse.borwe2.testnet -
npm run deploy:contract
This builds, the contracts, and deploys the main one, also requires the ./neardev/dev-account.env to exist, from previous step.
This command will prompt user for account to be used as owner of the main contract, this will be admin account id for that contract. Pass in the account you used in near login for it to work.
-
npm run test_service
This will run the tests, and simulate what a user might perform on your contracts.
Must have a typescript file at ./neardev/test_obj.ts which contains the information for the test to use, which should follow the following setup
export const ACCOUNT = "borwe2.testnet"; export const PRIVATE_KEY = "ed25519:SOMETHINGSOMETHING12312321432545";
The
PRIVATE_KEY
Can be found from the home directory at:~/.near-credentials/testnet/account.name.json
Here
account.name
being the account id you used during login in the first command. eg: borwe2.testnet would be mine, which should be also the value you put in theACCOUNT
variable on the ./neardev/test_obj.ts fileNOTE: private key starts from the string
ed25519:
inclusive.
- The "backend" code lives in the
/contract
folder. See the README there for more info. - The frontend code lives in the
/src
folder./src/main.ts
is a great place to start exploring. can learn how the frontend connects to the NEAR blockchain. - Tests: there are different kinds of tests for the frontend and the smart
contract. See
contract/README
for info about how it's tested. The frontend code gets tested with karma + jasmine. You can run both of these at once withnpm run test
.
On Windows, if you're seeing an error containing EPERM
it may be related to spaces in your path. Please see this issue for more details.