Solidity REPL
Contracts & calls

Use an imported repository file

Import a library from a repository-shaped path and call it from the REPL.

Solidity 0.8.36REPL modeRepository import

Why use this example

Use this workflow after bringing a library, interface, or contract into Files from public Git. The repository path becomes part of the Solidity import, while the symbol it defines works like any other Solidity declaration.

Solidity to run

import "./math-kit/src/PercentMath.sol"

uint256 gross = 2 ether
uint256 fee = PercentMath.percentOf(gross, 15)
fee

Official Solidity reference

Compare this focused investigation with the complete language definition in the Solidity documentation.

Solidity import paths

Use a file imported from Git

This runnable version preloads a small file under a repository-shaped path. To use a file from your own public repository:

  1. Open Files → Import public Git repository.
  2. Paste the public HTTPS repository URL. Optionally choose a branch, tag, or subdirectory, then select Scan repository.
  3. Select the Solidity file and choose Import selected. Dependencies referenced by its relative imports are included automatically.
  4. Copy the path shown in Files into a relative Solidity import, then call the library, contract, or interface it defines.
import "./math-kit/src/PercentMath.sol"
PercentMath.percentOf(2 ether, 15)
Keep the repository-name prefix. If Files shows math-kit/src/PercentMath.sol, import ./math-kit/src/PercentMath.sol exactly, including capitalization.

Included repository file

The clickable example preloads this file before compiling the entry, matching the path created by a repository import.

math-kit/src/PercentMath.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.20;

library PercentMath {
  function percentOf(uint256 amount, uint256 rate) internal pure returns (uint256) {
    return amount * rate / 100;
  }
}

What to expect

The repository-shaped import resolves PercentMath and calculates a 15 percent fee on 2 ether as 300000000000000000 wei.

Continue the investigation

Change a value, add another expression, or open Inspect after the run. Accepted entries remain available to the next entry, and the clean replay keeps the complete result reproducible.

Read about calls and logs Reproducible investigation