Comments on: Smart Contracts in Python: Complete Guide https://sesamedisk.com/smart-contracts-in-python-complete-guide/ Sat, 18 Jun 2022 22:45:22 +0000 hourly 1 https://wordpress.org/?v=6.4.3 By: Syed Umar Bukhari https://sesamedisk.com/smart-contracts-in-python-complete-guide/#comment-529 Sat, 18 Jun 2022 22:45:22 +0000 https://sesamedisk.com/?p=4842#comment-529 In reply to Hamid.

I am glad to hear that.

]]>
By: Syed Umar Bukhari https://sesamedisk.com/smart-contracts-in-python-complete-guide/#comment-528 Sat, 18 Jun 2022 22:45:00 +0000 https://sesamedisk.com/?p=4842#comment-528 In reply to Hamid.

In that case if it still didn’t fix your python smart contract issue, I think entering the full path might help you.

]]>
By: Hamid https://sesamedisk.com/smart-contracts-in-python-complete-guide/#comment-527 Sat, 18 Jun 2022 11:36:34 +0000 https://sesamedisk.com/?p=4842#comment-527 In reply to Syed Umar Bukhari.

I solved this problem and made an article in medium, maybe help someone else.
https://athamidn.medium.com/deploy-multi-file-smart-contracts-with-python-798a5d7cfa13

]]>
By: Hamid https://sesamedisk.com/smart-contracts-in-python-complete-guide/#comment-525 Fri, 17 Jun 2022 14:24:53 +0000 https://sesamedisk.com/?p=4842#comment-525 In reply to Syed Umar Bukhari.

This is my py file:
import json
from solcx import compile_standard, install_solc
import os

install_solc("0.8.0")

with open('./SC.sol', 'r') as smartContract:
currentSC = smartContract.read()

compiled_sol = compile_standard(
{
"language": "Solidity",
"sources": {"SC.sol": {"content": currentSC}},

"settings": {
"outputSelection": {
"*": {"*": ["abi", "metadata", "evm.bytecode", "evm.sourceMap"]}
},
},
},
solc_version="0.8.0",
)
print(compiled_sol)

———-
this is my SC.sol :
pragma solidity ^0.8.0;

import "./SafeERC20.sol";

contract ChildContract {
address private owner;
address private mainContractAddress;
using SafeERC20 for IERC20;

constructor(address _owner) {
owner = _owner;
mainContractAddress = msg.sender;
}

modifier onlyOwner() {
require( msg.sender == mainContractAddress || msg.sender == owner , "Access denied!" );
_;
}
.....

—–
and this is my SafeErc20.sol:

pragma solidity ^0.8.0;

import "./IERC20.sol";
import "./Address.sol";

/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for addr

...
are are same directory, but still I have that error message 🙁

]]>
By: Syed Umar Bukhari https://sesamedisk.com/smart-contracts-in-python-complete-guide/#comment-524 Fri, 17 Jun 2022 01:32:32 +0000 https://sesamedisk.com/?p=4842#comment-524 In reply to Hamid.

Hi, Hamid. From what I understand of the problem you face in python smart contracts code is an import error. Did you try this to fix the python smart contract error? When you import something in the same directory, you should start with “./” so basically do “./bxyz” instead of just the name because then it treats it as an absolute path which won’t work. Hope it helps. Let me know if solved the smart contracts python error, thanks.

]]>
By: Hamid https://sesamedisk.com/smart-contracts-in-python-complete-guide/#comment-523 Thu, 16 Jun 2022 14:12:24 +0000 https://sesamedisk.com/?p=4842#comment-523 I have a problem
my smart contract has an import other contract

a.sol import b.sol
these are in the same folder
but when I compile it , I get an error:

{"errors":[{"component":"general","errorCode":"6275","formattedMessage":"ParserError: Source \"SafeERC20.sol\" not found: File outside of allowed directories.\n -->

]]>