Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it a working contract? #1

Open
naddika opened this issue Sep 1, 2021 · 8 comments
Open

Is it a working contract? #1

naddika opened this issue Sep 1, 2021 · 8 comments

Comments

@naddika
Copy link

naddika commented Sep 1, 2021

Is it a working contract? Can be used in a real environment?

@BryanMorgan
Copy link
Owner

Yes, this is a working contract. You can deploy it and test it yourself on Devnet or Mainnet. But I would consider this just a starter template for a real rental agreement since there are probably more features and validation you'd want to include besides just the basics here.

@naddika
Copy link
Author

naddika commented Sep 3, 2021

@BryanMorgan I see.

What those features and validation would be, for instance?

@BryanMorgan
Copy link
Owner

For example:

  • Right now the contract is setup with a deposit and rental terms, but there is no instruction to refund the deposit. Should this happen immediately after the last payment or as a separate transaction, only allowed if the contract is in a complete state?
  • There is an instruction to TerminateEarly, but under what conditions should that be allowed (or should it be removed?) and how can issue the instruction? Do you need both parties approval or just the owner (payee)?

@snowsky
Copy link

snowsky commented Dec 2, 2021

Hi @BryanMorgan, do you have an example for client side? Thanks :)

@BryanMorgan
Copy link
Owner

Right now I don't have a fully functional client-side example I can share. But I pulled out some of the key capabilities from a client example I am working on and shared it in this Gist. Hopefully that's enough to get you started with the 3 key steps:

  • Create a rent share account
  • Initialize the rental agreement with the terms (deposit, rent, duration, keys)
  • Record a rental payment from a payer to a payee

It uses the @solana/web3.js library along with BN and borsh for big number and binary serialization support:

https://gist.github.com/BryanMorgan/2da2ed2b1ce8371d12812cfc2db6e73b

@snowsky
Copy link

snowsky commented Dec 6, 2021

Thanks @BryanMorgan

@zigomi
Copy link

zigomi commented Dec 20, 2021

But that requires duplicating all those AgreementStatus, RentDuration and other things.... in JS?

@BryanMorgan
Copy link
Owner

No, you don't have to. You don't even have to use a JavaScript/web3.js client. You could write a client in Rust and re-use the same definitions.

But if you're building a web3-based client it probably makes it easier to keep track of the data you're sending in TransactionInstructions if you model the contract schema data in JavaScript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants