lib.rs 599 B

1234567891011121314151617181920212223242526272829
  1. use borsh::{BorshDeserialize, BorshSerialize};
  2. use drk_sdk::{
  3. entrypoint,
  4. error::{ContractError, ContractResult},
  5. msg,
  6. };
  7. use pasta_curves::pallas;
  8. #[derive(BorshSerialize, BorshDeserialize)]
  9. pub struct Args {
  10. pub a: pallas::Base,
  11. pub b: pallas::Base,
  12. }
  13. entrypoint!(process_instruction);
  14. fn process_instruction(ix: &[u8]) -> ContractResult {
  15. let args = Args::try_from_slice(ix)?;
  16. if args.a < args.b {
  17. return Err(ContractError::Custom(69))
  18. }
  19. let sum = args.a + args.b;
  20. msg!("Hello from the VM runtime!");
  21. msg!("Sum: {:?}", sum);
  22. Ok(())
  23. }