4.1.2 Natural-Language-to-Solidity
Convert natural language into secure Solidity code using Avilom’s NL2Solidity AI endpoint.
🧠 Example
const prompt = \`
Create an ERC-20 token named "FanToken" with symbol "FANS",
initial supply 1,000,000, and a mint function restricted to owner.
\`;
const { solidityCode } = await sdk.nl2solidity.generate({ prompt });
console.log(solidityCode);
🧾 Output
pragma solidity ^0.8.10;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract FanToken is ERC20, Ownable {
constructor() ERC20("FanToken", "FANS") {
_mint(msg.sender, 1_000_000 * 10 ** decimals());
}
function mint(address to, uint256 amount) external onlyOwner {
_mint(to, amount);
}
}