LandWorks Widget
Be able to list and rent from everywhere!
How to install?
npm install @enterdao/landworks-widget --save
Examples
import { ListModal, RentModal } from '@enterdao/landworks-widget'
function App() {
const [wallet, setWallet] = useState('');
const [openRent, setOpenRent] = useState(false);
const [openList, setOpenList] = useState(false);
const provider = window.ethereum
? window.ethereum
: window.web3.currentProvider;
const connect = () => {
provider
? provider
.request({ method: 'eth_requestAccounts' })
.then((wallet: string[]) => setWallet(wallet[0]))
: alert('No wallet founds');
};
return (
<div >
<header >
{wallet.length ? (
<>
<RentModal
open={openRent}
onClose={() => setOpenRent(false)}
account={wallet}
assetId={'1'}
referrer={'1'}
provider={provider}
/>
<ListModal
open={openList}
onClose={() => setOpenList(false)}
account={wallet}
tokenId={'2'}
tokenAddress={'0x0000000000000000000000000000000000000000'}
referrer={'1'}
provider={provider}
/>
<b>Address : {wallet}</b>
<div style={{ display: 'flex', gap: '20px' }}>
<button onClick={() => setOpenRent(true)}>
Show rent modal
</button>
<button onClick={() => setOpenList(true)}>
Show list modal
</button>
</div>
</>
) : (
<button onClick={connect}>
Connect wallet
</button>
)}
</header>
</div>
);
}
export default App;
Props Reference
Common
Prop | Description |
---|
open: boolean | Boolean, triggering the opening of the modal. |
onClose() | Callback function, called upon modal closing. |
onError(error) | Callback function, called upon error. |
onSuccess(txReceipt) | Callback function, called after contract execution has been mined. |
provider | MetaMask Web3 provider. |
account: string | EVM wallet address, connected to provider . |
referrer: string | EVM wallet address, passed as referrer upon listing and renting. |
Rent modal
Prop | Description |
---|
assetId: string | The LandWorks AssetId for which the rent modal will open. |
List modal
Prop | Description |
---|
tokenAddress: string | Address of the ERC-721 collection |
tokenId: string | Token ID from the ERC-721 collection |