[Report] #2 Phoenix Zero - Vehicle History and Service Tracker (Feb 11→ 28, 2022)

Project title: Vehicle History and Service Tracker

One-liner: Development of app that allows a user to add vehicles and vehicle services to the blockchain

Project Summary: Project consists of three repos, a smart contract that uses near-sdk-core , where a user can add vehicles and vehicles services to the blockchain. The second repo is a front-end repo the uses Vue.js and near-api-js to render the state of the contract on a browser. The third repo will is a smart contract that contains code to hold Vehicle contract and assign that contract to a specific user.

Developer in Residence:
discord: phoenixpulsar | A Macedo#8225

Period:
Feb 11→ 28, 2022

Summary of work done (41hrs)

  • Smart Contract 2

    • Forked Meme museum and modify to be able to deploy a contract per user
    • https://github.com/phoenixpulsar/vehicle-history-garage
    • Worked on creating sub-accounts to deploy contract
  • Front End

    • https://github.com/phoenixpulsar/vehicle-history-front-end
    • URL: vhfe
    • Added login logic using Wallet
    • Added logic to access change methods from smart contract (nearAPI.contract())
    • https://github.com/phoenixpulsar/vehicle-history-smart-contract
    • Created UI/UX wireframes to add more style to Contract
  • Other

    • Presented current state of project at AMA Feb 25, 2022

Next Steps/Ongoing

  • ONGOING: Allow a logged in user to create a contract and filter on his/hers Vehicles and Vehicles Services
  • ONGOING: Debug sub-account permissions to delete contracts/accounts
  • ONGOING Add more css/style/flare
  • TODO Finish CRUD operations on Vehicle History Contract
  • TODO: Create Blog/Tutorial to create CRUD dApp in English/Spanish
  • TODO: Allow a user to sell a vehicle to another user using NEAR coin
  • TODO: Investigate limits of RPC how to index or store if state grows above 50kb of state

Block 1 (9hrs)

  • Front-End
    • Added login/logout functionality using NEAR wallet
    • View and render logged in user details, display logged in User account
    • Debug login, on requestSignIn from wallet connection, getting account incorrect, will give the following error Server error: accountId xxxx does not exist while viewing
    • Use Vuex store for Vue components to read and interact with contract
    • Minor spike on assemblyscript asbuild, asb is a build tool for projects such as cargo is for rust [https://github.com/AssemblyScript/asbuild](https://github.com/AssemblyScript/asbuild)

Block 2 (6hrs)

  • Front-End
    • Created UI/UX wireframes to add more flare to project
    • Created presentation of current status of project for AMA call on Discord NEAR University

Block 3 (20hrs)

  • Smart Contract

    • Forked and played with Meme Museum. Meme museum works in a similar way we want our vehicle history project to work. That is, we want to have users have their own vehicle contracts. So we can modify the Museum to be our “Vehicle Garage” and the “Meme” to be our “Vehicle”
    // import vehicle contract bytecode as StaticArray
    const CODE = includeBytes("../../../build/release/vehicle.wasm")
    
    let promise = ContractPromiseBatch.create(accountId)
    .create_account()
    .deploy_contract(Uint8Array.wrap(changetype<ArrayBuffer>(CODE)))
    .add_full_access_key(base58.decode(context.senderPublicKey))
    
    • Adding a meme is analogous to adding a vehicle contract, once we have a vehicle contract, we want to add a vehicle or a service so calling functions on vehicle, similar to how we call vote on
    • Created assertion to only limit who can call a method on smart contract
    function is_owner(): bool {
    	return VehicleGarage.has_owner(context.predecessor)
    }	
    function assert_signed_by_owner(): void {
    	assert(is_owner(), "This method can only be called by a VehicleGarage owner")
    }	
    static has_owner(account: AccountId): bool {
    	return owners.has(account)
    }	
    const owners = new PersistentSet<AccountId>("o")
    
    • Use and created sub-accounts to deploy contracts

      • https://docs.near.org/docs/tools/near-cli#near-create-account
    • Sign In error, if trying to call a method on a contract and get the following error

      • Error: Can not sign transactions for account xxxxx.testnet on network testnet, no matching key pair found in InMemorySigner is probably because you are not logged in, so do near login from command line CLI
    • Debugging how to delete a meme or in our case a vehicle

      • remove_meme function. I get the following message. Failure [yyyy.xxxx.testnet]: Error: Actor yyyy.xxxx.testnet doesn't have permission to account usain.yyyyy.xxxxx.testnet to complete the action I can’t seem to figure out why this is happening, specially since I would think that on add_meme we add a full access key .add_full_access_key(base58.decode(context.senderPublicKey)) and that creating the account yyyy.xxxx.testnet with --masterAccount xxxx.testnet would give access to the master account to perform operation on the account created.

Block 4 (6hrs)

  • Front-End
    • Allow a user to add a vehicle from the Front-End (interact with change method(addVehicle()) from Smart Contract)
    • Allow a user to add a service to a Vehicle from the Front-End (interact with change method(addService()) from Smart Contract)