The Solidity Contract-Oriented Programming Language - By chatting here you agree to the https://github.com/ethereum/solidity/blob/develop/CODE_OF_CONDUCT.md
push32 0x...
as opposed to a typical push1 val; sload
. So 33
bytes v/s 3
---around 6000 gas. Also, the init code will be more complex for immutables.
Does anyone use coinbase for liquidity mining ETH like I do?
Me
emscripten-wasm32
platform. The binary for that version can be found for different platforms, but I really needed it for emscripten-wasm32
.hardhat/=node_modules/hardhat/
but with symlink it is actually : hardhat/=../../node_modules/.pnpm/hardhat-deploy@0.9.3_hardhat@2.6.5/node_modules/hardhat-deploy
which solc does not seem to be aware of as it complained about not found: File outside of allowed directories.
@qq5678: TLDR the syntax is __address_to__.transfer(__amount__)
where __address_to__
is the address to send funds, and __amount__
is the amount in Wei to send.
Here's an example for demonstrating how to deposit and withdraw from a smart contract;
Account.sol
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.7;
/// @title Example contract for holding and distributing funds
/// @author S0AndS0
contract Account {
address payable public owner;
uint256 public balance;
///
constructor(address payable _owner) payable {
owner = _owner;
balance = msg.value;
}
///
function deposit() external payable {
balance += msg.value;
}
///
function withdraw(uint256 _amount) external {
require(msg.sender == owner, "Message sender not contract owner");
require(_amount <= balance, "Insufficient funds for withdraw");
owner.transfer(_amount);
balance -= _amount;
}
}
And for completeness here's an example of how to initialize, and pay, a smart contract from a separate factory contract... plus a few bonus features;
Bank.sol
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.7;
/// @title Example factory for making new accounts and getting initialized accounts
/// @author S0AndS0
contract Bank {
/* Account.owner to address(Account) */
mapping(address => address) accounts;
///
function initializeAccount(address payable _account_owner)
external
payable
returns (Account)
{
require(
accounts[_account_owner] == address(0x0),
"Account already initalized"
);
Account _account = (new Account){ value: msg.value }(_account_owner);
accounts[_account_owner] = address(_account);
return _account;
}
///
function getAccount(address _account_owner)
external
view
returns (Account)
{
address _account_reference = accounts[_account_owner];
require(_account_reference != address(0x0), "Account not initalized");
return Account(_account_reference);
}
}
payable(address(this).balance).transfer(member1);
it returns me this error TypeError: Explicit type conversion not allowed from "uint256" to "address payable"
Contact eth@consultant.com
I'm trying to install Solidity compiler to work with Z3 (Mac). I tried 2 things:
1) I installed from source with Z3 present brew install solidity
(from what I understand in the documentation the build should install with Z3 support unless explicitly disabled with a flag)
2) I installed z3 separately brew install z3
Then I run solc simple.sol --model-checker-engine bmc --model-checker-solvers z3
, however, solc is reporting the following:
Warning: BMC analysis was not possible since no SMT solver was found and enabled.
Any idea how to get this to work?
using
statement
It's hard to tell what's really happening without more details. Do you have cmake output from the build?
You could submit an issue with more details in the bug tracker and we'll investigate.
As a workaround, you could try our own formula that has a dependency on z3: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/solidity.rb
Or try a static binary from solc-bin - these have Z3 statically compiled-in: https://github.com/ethereum/solc-bin/tree/gh-pages/macosx-amd64
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract Test1{
uint private a1 = 11;
function get() public view returns (uint){
return a1;
}
function set(uint a) public{
a1=a;
}
function set1() public {
a1=22;
}
fallback() external {
a1=33;
}
}
contract Test2{
function call_1(address contractAddress) public{
(bool success,bytes memory a) =contractAddress.call(abi.encodeWithSignature("set(uint)",44));
require(success);
}
function call_2(address contractAddr) public {
(bool success,) = contractAddr.call(abi.encodeWithSignature("set1()")); require(success);
require(success);
}
}
function "call_1" does not work