MCP Smart Contracts icon

MCP Smart Contracts

Despliega un contrato inteligente de alquiler en la blockchain usando Hardhat

Overview

This node deploys a rental smart contract on a blockchain using Hardhat. It automates the creation of a blockchain contract for renting an asset by specifying details such as asset type, rental duration, payment amount, currency, deposit, and renter's address. This is useful in scenarios where users want to programmatically create rental agreements on-chain without manually interacting with blockchain deployment tools.

Practical examples include:

  • Deploying a smart contract for renting a mountain bike for 3 days at $50 with a $10 deposit.
  • Creating rental contracts for various assets like vehicles, equipment, or property with customizable terms.

Properties

Name Meaning
Tipo De Activo Type of asset to be rented (e.g., "bicicleta de montaña")
Duración Duration of the rental period (e.g., "3" days)
Monto Rental amount to be paid (e.g., "50.0")
Moneda O Unidad Currency or unit of the rental amount (e.g., "USD")
Depósito Deposit amount required for the rental (e.g., "10.0")
Dirección Del Arrendatario Blockchain address of the renter

Output

The node outputs a JSON object per input item containing:

  • tipo_activo: The asset type provided as input.
  • duracion: Rental duration.
  • monto: Rental amount.
  • moneda_o_unidad: Currency or unit.
  • deposito: Deposit amount.
  • renter_address: Renter's blockchain address.
  • contractAddress: The deployed smart contract's blockchain address if deployment succeeded; empty string otherwise.
  • error: Error message if deployment failed; empty string otherwise.

No binary data output is produced.

Dependencies

  • Requires Node.js environment with child_process module available.
  • Uses Hardhat framework installed and configured in the environment where the node runs.
  • Requires .env file support via dotenv package for environment variables (though no specific variables are referenced in the code).
  • Assumes presence of a Hardhat project with a compiled RentalContract smart contract.
  • No explicit API keys or external services are needed beyond blockchain node access configured in Hardhat.

Troubleshooting

  • Common issues:

    • Failure to deploy contract due to missing or misconfigured Hardhat environment.
    • Errors if the RentalContract smart contract is not compiled or not present.
    • Invalid renter address format causing deployment failure.
    • Insufficient permissions or blockchain node connectivity issues.
  • Error messages:

    • "No se pudo obtener la dirección del contrato." indicates the contract address was not returned after deployment, possibly due to deployment failure.
    • Other error messages from the child process execution are captured and returned in the error field.
  • Resolutions:

    • Ensure Hardhat is properly installed and configured.
    • Verify the smart contract source and compilation.
    • Check that the renter address is valid and correctly formatted.
    • Confirm blockchain node access and credentials if applicable.

Links and References

Discussion