cienicera / p5.js-mint

The p5.js Editor is a website that integrates p5.js, a popular JavaScript library used for creative coding and visual arts, with the functionality to mint SVG NFTs on Starknet. The project aims to provide a streamlined process for generative artists to create and mint unique digital art pieces as NFTs directly from their p5.js code.
https://editor.p5js.org
GNU Lesser General Public License v2.1
0 stars 8 forks source link

Smart Contract Interactions #12

Open caseywescott opened 1 month ago

caseywescott commented 1 month ago

Increasing Access

Ensure that the p5.js Web Editor correctly interfaces with the deployed Starknet smart contracts.

Feature request details

This involves validating that the contract functions are called correctly, handling different scenarios like successful transactions, failed transactions, and edge cases, and ensuring that the interaction between the frontend and the blockchain is secure, efficient, and reliable. Proper testing helps prevent issues during the minting process and ensures a smooth user experience.

Tasks:

Set Up a Testing Environment:

Deploy the smart contract on a Starknet testnet to create a controlled environment for testing interactions. If applicable, set up a local development environment using tools like Starknet Devnet to simulate blockchain interactions without incurring real transaction costs.

Ensure that the testing environment mirrors the production setup as closely as possible, including contract versions, configurations, and network conditions.

Write Test Cases for Contract Functions:

Minting Functionality: Test the contract’s minting function, ensuring that it correctly accepts SVG data and mints it as an NFT. Verify that the minted NFT contains the correct metadata and is assigned to the correct owner. Error Handling: Test how the contract handles invalid inputs or insufficient gas fees. Verify that errors are properly caught and communicated back to the frontend.

Approval and Transfer: If the contract supports transfer or approval of NFTs, test these functions to ensure they work as expected and interact correctly with the wallet.

Simulate Various User Scenarios:

Successful Transaction: Simulate a successful minting transaction, ensuring that the user receives a confirmation and that the NFT is minted on the blockchain.

Failed Transaction: Test scenarios where transactions fail due to issues like insufficient funds, contract rejections, or network errors. Ensure that these failures are handled gracefully by the frontend, with clear error messages provided to the user.

Network Issues: Simulate network latency or disruptions to see how the system handles transaction delays or failures. Verify that the UI provides appropriate feedback and that users can retry or cancel the transaction if necessary.

Test Edge Cases and Limits:

High-Volume Transactions: Test how the smart contract and the frontend handle a high volume of minting requests. Ensure that the system remains stable and responsive under load.

Large SVG Data: Test the minting process with large or complex SVG data to ensure that the contract can handle the data size and that the frontend manages the transaction efficiently.

Multiple Wallets: If applicable, test interactions from multiple wallets, ensuring that the contract correctly handles different users and does not mix up transactions.

Security Testing:

Transaction Integrity: Ensure that the data sent to the contract is secure and has not been tampered with. Test for potential security vulnerabilities, such as replay attacks or data injection.

User Authentication: Verify that only authenticated users can interact with the smart contract and that unauthorized access is prevented.

Reentrancy and Overflow: Test the contract for common smart contract vulnerabilities like reentrancy attacks or integer overflows, ensuring that these are handled correctly.

Performance Testing:

Response Time: Measure the response time of the contract functions, especially under varying network conditions. Ensure that transactions are processed within acceptable timeframes and that the UI remains responsive. Gas Optimization: Monitor the gas usage for various contract functions, ensuring that they are optimized for efficiency. Identify and address any functions that consume excessive gas.

ShantelPeters commented 3 weeks ago

Hi @caseywescott can I work this ?

onlydustapp[bot] commented 3 weeks ago

Hi @ShantelPeters! Maintainers during the ODHack # 7.0 will be tracking applications via OnlyDust. Therefore, in order for you to have a chance at being assigned to this issue, please apply directly here, or else your application may not be considered.

PoulavBhowmick03 commented 3 weeks ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I'm Poulav Bhowmick, a software engineer at Invisible Studios with a robust background in TypeScript, Rust, Solidity Cairo, fullstack development and blockchain technology. My experience includes building robust applications, optimizing functionalities and blockchain integration. I have actively participated in events and open source contributions, enhancing my capability to tackle real-world tech challenges. My projects can be viewed on my GitHub Profile and OnlyDust Profile. Plus I´m active member of Starknet community🇷.

How I plan on tackling this issue

  1. Set Up a Testing Environment

Deploy on Starknet Testnet: I would first deploy the smart contract to the Starknet testnet, creating a controlled environment to simulate real-world interactions. This ensures that all tests are conducted under conditions similar to production.

Local Development Environment: If applicable, I would set up a local development environment using tools like Starknet Devnet. This allows me to simulate blockchain interactions without incurring real transaction costs and provides a sandbox for more granular testing.

Mirror Production Setup: I would ensure the testing environment mirrors the production setup as closely as possible. This includes matching contract versions, configurations, and network conditions to avoid any discrepancies between testing and production.

  1. Write Test Cases for Contract Functions

Minting Functionality: I would write comprehensive test cases for the minting function, ensuring that the contract correctly accepts SVG data and mints it as an NFT. Each test would verify that the minted NFT contains the correct metadata and is assigned to the intended owner.

Error Handling: I’d create tests for various error scenarios, such as invalid inputs or insufficient gas fees, ensuring that these errors are properly caught and communicated back to the frontend.

Approval and Transfer: If the contract supports NFT transfers or approvals, I would test these functions, ensuring they work as expected and interact correctly with the connected wallet.

  1. Simulate Various User Scenarios

Successful Transaction: I would simulate a successful minting transaction, verifying that the user receives confirmation and that the NFT is successfully minted on the blockchain.

Failed Transaction: I’d test failure scenarios, such as insufficient funds or contract rejections, ensuring that the frontend handles these gracefully with clear error messages.

Network Issues: I’d simulate network latency or disruptions to see how the system handles delays or failures. The UI should provide appropriate feedback, and users should be able to retry or cancel the transaction.

  1. Test Edge Cases and Limits

High-Volume Transactions: I would test how the smart contract and frontend handle a high volume of minting requests, ensuring system stability and responsiveness.

Large SVG Data: I would test the minting process with large or complex SVG data to ensure that the contract can handle the data size and that the frontend processes the transaction efficiently.

Multiple Wallets: I’d test interactions from multiple wallets, ensuring the contract correctly handles different users and maintains transaction integrity.

  1. Security Testing

Transaction Integrity: I would validate that the data sent to the contract is secure and tamper-proof, testing for vulnerabilities like replay attacks or data injection.

User Authentication: I’d verify that only authenticated users can interact with the smart contract, ensuring unauthorized access is prevented.

Reentrancy and Overflow: I’d conduct tests for common smart contract vulnerabilities like reentrancy attacks or integer overflows, ensuring these are adequately handled.

  1. Performance Testing

Response Time: I would measure the response time of contract functions under varying network conditions, ensuring transactions are processed within acceptable timeframes and the UI remains responsive.

Gas Optimization: I would monitor gas usage for contract functions, optimizing them for efficiency and addressing any that consume excessive gas.

  1. Documentation and Reporting

Document the Testing Process: I would document all test cases, scenarios, and results, ensuring clear communication of findings and any issues that arise.

Feedback Loop: I would maintain a feedback loop with developers, ensuring that any bugs or inefficiencies identified during testing are quickly addressed and resolved.

ETA- 3 days

MPSxDev commented 3 weeks ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Lately, I have been immersing myself deeply in Cairo and Starknet, dedicating significant time to mastering these cutting-edge technologies. My journey includes participation in numerous bootcamps and continuous training sessions, which have provided me with a solid foundation and advanced expertise in this domain. Additionally, I have actively engaged in recent hackathons, where I applied my skills in Cairo to build innovative solutions, further honing my abilities and staying at the forefront of the rapidly evolving blockchain ecosystem. My experience in these competitive environments has equipped me with the agility and problem-solving skills. I am part of the Dojo Coding community.

How I plan on tackling this issue

I am fully available. The work consists of the following steps:

  1. Set up Starknet testnet and Devnet.
  2. Test SVG minting and error handling.
  3. Simulate successful/failed transactions.
  4. Assess high load and large SVGs.
  5. Verify security and performance.
  6. Correct until we achieve what we want
JorgeOehrens commented 2 weeks ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

We develop smart contracts in Solidity for Ethereum's testnet and mainnet, and we use Next.js and React with TypeScript for the front end. Now, we're starting smart contract development on the Stellar blockchain using Soroban (Rust).

I use Wagmi for wallet connections and hooks, and I've found it very effective. After reading the documentation, I have a good idea of how to implement something similar to the useWatchContractEvent hook.

My focus is on maintaining clean, scalable code that aligns with the structure and quality of our existing codebase.

How I plan on tackling this issue

To approach the problem of ensuring that the p5.js Web Editor correctly interfaces with the deployed Starknet smart contracts, the process can be broken down into several key steps that involve setting up the environment, conducting thorough testing, and validating the interaction between the frontend and the blockchain to ensure security, efficiency, and reliability.

First, it is essential to set up a testing environment. This involves deploying the smart contract on the Starknet testnet to create a controlled environment that simulates real-world conditions. Additionally, setting up a local development environment using tools like Starknet Devnet can help simulate blockchain interactions without incurring real transaction costs. It is crucial that the testing environment mirrors the production setup as closely as possible, including contract versions, configurations, and network conditions. Monitoring tools should be set up to observe the interaction between the frontend and the blockchain in real-time.

Next, writing test cases for the contract functions is critical. The minting functionality should be tested to ensure that the contract correctly accepts SVG data and mints it as an NFT, with the minted NFT containing the correct metadata and being assigned to the correct owner. Error handling should also be tested, focusing on how the contract handles invalid inputs, such as malformed SVG data or insufficient gas fees, and ensuring that these errors are properly caught and communicated to the frontend. If the contract supports the transfer or approval of NFTs, those functions should also be tested to ensure they work as expected and interact correctly with the user's wallet.

Simulating various user scenarios is another important step. This includes simulating a successful minting transaction to ensure that the user receives confirmation and that the NFT is correctly minted on the blockchain. Failed transactions should also be simulated, testing scenarios where transactions fail due to issues like insufficient funds, contract rejections, or network errors. The frontend should handle these failures gracefully, providing clear error messages to the user. Additionally, network issues such as latency or disruptions should be simulated to see how the system handles transaction delays or failures, ensuring that the UI provides appropriate feedback and allows users to retry or cancel the transaction if necessary.

jrmncos commented 2 weeks ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I'm a Software Engineer Backend SR. But I have experience with React and some of Cairo too.

How I plan on tackling this issue

I would use Starknet sdk to invoke the contract functions. I would collect the parameters probably from redux store, and then to I will request againts the contract and handle errors.