Buy, sell, and manage your properties with Real Estate Registry (ESR), using The Graph protocol. Track bid and transaction history. Buy in ETH and convert ETH to INR.
https://gateway-testnet-arbitrum.network.thegraph.com/api/{api-key}/subgraphs/id/FgZp62jkWu3qkmw82Z5xoWMzQws9xYhHtyUHA5gPmja5
curl -X POST \
-H "Content-Type: application/json" \
-d '{"query": "{ confirmations(first: 5) { id owner operation blockNumber } revokes(first: 5) { id owner operation blockNumber } }", "operationName": "Subgraphs", "variables": {}}' \
https://gateway-testnet-arbitrum.network.thegraph.com/api/{api-key}/subgraphs/id/FgZp62jkWu3qkmw82Z5xoWMzQws9xYhHtyUHA5gPmja5
const { request, gql } = require('graphql-request');
const endpoint = 'https://gateway-testnet-arbitrum.network.thegraph.com/api/{api-key}/subgraphs/id/FgZp62jkWu3qkmw82Z5xoWMzQws9xYhHtyUHA5gPmja5';
const query = `{
confirmations(first: 5) {
id
owner
operation
blockNumber
}
revokes(first: 5) {
id
owner
operation
blockNumber
}
}`;
async function fetchData() {
try {
const data = await request(endpoint, query);
console.log(data);
} catch (error) {
console.error('Error fetching data:', error);
}
}
fetchData();
- propertiesWithGraph
query {
propertiesWithGraph {
id
name
details
priceINR
priceETH
walletAddress
}
}
- propertiesByWallet
query($walletAddress: String!) {
propertiesByWallet(walletAddress: $walletAddress) {
id
name
details
priceINR
priceETH
walletAddress
}
}
- confirmations
query {
confirmations {
id
blockNumber
transactionHash
}
}
- revokes
query {
revokes {
id
blockNumber
transactionHash
}
}
- createProperty
mutation {
createProperty(
name: "Test Property"
details: "This is a test property"
priceINR: 100
priceETH: 0.1
walletAddress: "0x1234567890abcdef"
) {
id
name
details
priceINR
priceETH
walletAddress
}
}
- getProperty
query($id: String!) {
getProperty(id: $id) {
id
name
details
priceINR
priceETH
walletAddress
}
}
- registerUser
mutation {
registerUser(
walletAddress: "0x1234567890abcdef"
) {
id
walletAddress
testTokens
}
}
- transferProperty
mutation {
transferProperty(
propertyId: "1234567890abcdef"
newOwner: "0x9876543210fedcba"
) {
message
}
}
contract-protocol\contracts\registry.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract PropertyRegistry {
struct Property {
uint256 id;
string description;
address owner;
}
mapping(uint256 => Property) public properties;
uint256 public nextPropertyId;
event PropertyRegistered(uint256 id, address owner, string description);
event PropertyTransferred(uint256 id, address from, address to);
function registerProperty(string memory _description) public {
properties[nextPropertyId] = Property(nextPropertyId, _description, msg.sender);
emit PropertyRegistered(nextPropertyId, msg.sender, _description);
nextPropertyId++;
}
function transferProperty(uint256 _propertyId, address _newOwner) public {
require(properties[_propertyId].owner == msg.sender, "Only the owner can transfer the property");
properties[_propertyId].owner = _newOwner;
emit PropertyTransferred(_propertyId, msg.sender, _newOwner);
}
function getProperty(uint256 _propertyId) public view returns (Property memory) {
return properties[_propertyId];
}
}