Questions tagged [libraries]
The libraries tag has no usage guidance.
14
questions
0
votes
0
answers
10
views
How to Retrieve Library Addresses Linked to a Smart Contract on Etherscan?
I've run into a situation where I need to identify the library addresses that a verified contract is linked to. I understand that during the contract verification process on Etherscan, one must ...
0
votes
1
answer
22
views
Differences between function visibility features in Libraries
Function visibility in Libraries seems to provide different set of features than in ordinary contracts.
I think that also depends on the library type - if it is externally deployed or if it's code is ...
0
votes
0
answers
10
views
I am looking for resources to research on how to create a library that interacts with the blockchain (ether js like)
I know it's complex, and I know it's extremely hard, but I just want to take a look at how things are created. I want to create a library that interacts with the blockchain exactly the way ethers js ...
0
votes
1
answer
125
views
Solidity libraries "using A for B"
Concerning the usage of Solidity libraries, is there a difference between using:
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
contract Random {
using SafeMath for uint256;
...
0
votes
1
answer
82
views
Variable of interface type ? what is the purpose of giving interface name as variable type?
//SPDX-License-Identifier:MIT
pragma solidity ^0.8.6;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract staking{
IERC20 public s_stakingToken;
IERC20 public ...
4
votes
1
answer
191
views
Low level delegatecalls from contract to deployed library issues
I'm looking to make low-level delegatecall to a library that can be changed via a setter on the contract(see code below). Within the library, I am looking to make state changes to the calling contract....
6
votes
2
answers
784
views
Should I use Embedded Library (Internal) or Linked Library (External) to save gas?
I am aware that in solidity there are two types of libraries.
Embedded Library: If a smart contract is consuming a library which
have only internal functions than EVM simply embeds library into the
...
2
votes
1
answer
349
views
When importing a library from multiple contracts, is one library deployed, or multiple ones?
When importing a library from different contracts, is only one library deployed or multiple ones?
Take the following file structure:
lib.sol
contractA.sol
import './lib.sol';
contract A {}
...
0
votes
1
answer
506
views
Solidity upgradeable linked Libraries
What would be the best way to deploy upgradeable libraries?
If I am not mistaken, when deploying a contract that uses linked libraries, the contract's bytecode contains the libraries addresses, which ...
3
votes
0
answers
371
views
Embedded vs linked libraries
I recently became aware of linked vs embedded libraries. My understanding is that if your library uses public pure functions and/or manages storage, then you need to deploy and link the library to ...
0
votes
1
answer
103
views
How do you manipulate a storage struct array with an external library function?
Basic pseudocode mockup of my problem
import libraryB;
contract A{
struct Person{
string Name;
uint age;
}
Person[] public Party;
Party[0] = (Alice, 30);
libraryB.addAgeToPerson(Party[0], 1)
}
...
2
votes
2
answers
811
views
Why can I use Linked Libraries on Remix IDE without deploying them first?
I'm trying to understand the differences between Linked Libraries and Embedded Libraries.
I already read some articles and watched these tutorials:
https://www.youtube.com/watch?v=25MLAnIzXRw
https://...
6
votes
1
answer
414
views
Is it safe to mark library functions that modify the calling contract's state as public in Solidity?
I am using libraries to reduce the cost of deployment of a contract of which there may be many instances (using a factory contract). When I mark a library function as internal, the code seems to get ...
4
votes
2
answers
409
views
Does Solidity embed only the library functions that are consumed?
Suppose you have a library called MyAwesomeMathLib.sol, which contains only pure internal functions, and a contract Consumer.sol that consumes the library:
pragma solidity ^0.8.0;
import "./...