The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [library]

Libraries are reusable code. In the context of smart contracts, they are deployed only once at a specific address and their code is reused using DELEGATECALL.

26 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
3
votes
0answers
214 views

Benefits of library versus a plain contract (upgradeability)

I'm trying to find what the benefit is of a library. I found the following statements. (Please correct me if i'm wrong) Cost less gas to deploy Uses the storage of the calling contract the library ...
3
votes
0answers
190 views

What is the runtime performance of Ethereum Libraries compared to Contracts?

I'm looking for the cheapest way (in terms of gas price) to design upgradeable contracts. I don't expect many upgrades. Being inspired by Writing upgradable contracts in Solidity, I'm investigating ...
2
votes
0answers
27 views

Can I import a Library from a Library?

Is it possible to import a library into another library? I give a simplified example below of what I'd like to achieve: library structLib { struct Point { uint X; uint Y; } } ...
2
votes
0answers
96 views

Can I call a library function from a payable function?

I seem to get a revert each time I try this. I'm unable to get any useful revert message from truffle, so any assistance there might also help solve this. I have a library: library LibInterface { ....
2
votes
0answers
48 views

Which solidity dev environments support the use of already deployed library contracts?

So, I'm looking into using libraries in order to prevent re-deployment/re-use of the same code. I was hoping that I would be able to specify the address of a library in solidity code, using syntax ...
2
votes
1answer
141 views

Library function overloading

I have 3 libraries, one exposes struct and 2 others expose method with same signature/return type (first one provides default method implementation and second - extended and customized one). When ...
2
votes
0answers
164 views

delegatecall on library always run out of gas

I'm trying to replicate the Dynamic Library attack of this paper under a recent version of solidity and the EVM. Streamlining down the code, I've created this very simple contract (which is, in ...
2
votes
0answers
46 views

Can paritytech/parity be used as a library the same way that go-ethereum can be used in Go?

The go-ethereum project is divided into a set of standalone libraries that can be used in any Go project (e.g. smart contract interaction, keystore management, common cryptography and hex utils) Can ...
2
votes
0answers
111 views

Solidity libraries with public visibility

Suppose I have the following Contracts and a Library: pragma solidity ^0.4.21; library UserLib { function insertUser(address dbAddr, bytes32 user) public { DB(dbAddr).setUser(user); } } ...
2
votes
0answers
200 views

How to create a contract B that calls a library via contract A

As I understand it, the logic to deploy contract that uses library is as below: supposed that MetaCoin contract use TestLib library Deploy TestLib library first, then get a library contract address ...
2
votes
1answer
161 views

Library function access-level

I have a contract A, which has an instance of contract B, i.e., B b. Contract A calls a function of contract B via the instance, i.e., b.func(). Contract B is stateless, i.e., no global non-constant ...
2
votes
0answers
86 views

What's the value of `this` inside a library function when called via a delegatecall?

Imagine a contract C that makes a delegatecall to a library L. C -> L What's the value of this inside L: address(C) or address(L) ? If now that L makes a normal call to another contract D. C ->...
1
vote
0answers
27 views

Function selector computed differently for libraries?

As documented in various places, the function selector is computed as the first four bytes of the keccak256 hash of the function header, which consists of the function name followed by the list of ...
1
vote
0answers
33 views

Any C library available to interact with an Ethereum smart contract?

I need a C library that enables to create, sign transactions and interact with the smart contract.
1
vote
1answer
26 views

Ethereum linking library with contract not working as accepted…returning any state variable returns just the default value

my library pragma solidity ^0.5.8; library SafeMath { function add(uint256 a,uint256 b) public pure returns (uint256) { return a+b; } } My contract pragma solidity ^0.5.8; import ...
1
vote
0answers
45 views

Ethereum js wallet for php

https://github.com/ethereumjs/ethereumjs-wallet I need this library with the same functions in PHP Would u give me the link
1
vote
2answers
120 views

Is library use inherited?

When a base class uses a library, do derived classes also use the same library? For example: contract A { using SafeMath for uint256; ... } contract B is A { //is code here using ...
1
vote
0answers
54 views

Understanding Solidity Libraries using Solidity Docs code example

I was going through this code (see code below) about how to use libraries in solidity docs : https://solidity.readthedocs.io/en/v0.4.24/contracts.html?highlight=library#libraries and there are some ...
1
vote
2answers
183 views

Publishing contracts with libraries using web3.py

Im trying to publish contracts with libraries in them and im getting the below issue. Contracts without libraries publish just fine. Can someone who might have faced this issue before advise what the ...
1
vote
0answers
195 views

How to verify a contract with libraries deployed from Remix

I successfully deployed a contract with remix here on Ropsten Testnet: https://ropsten.etherscan.io/address/0x10273a926517b417015748da21e1287bab2da8f7 The Source Code is very simple but I'm using my ...
1
vote
1answer
253 views

implement solidity library with no overhead of external function calls

When reading the doc of Solidity.I found out that the following is hard to understand or maybe I misunderstood something, any help is much appreciated.The document says: The following example shows ...
0
votes
0answers
29 views

web3 - Can I call a library function without a contract?

I have a library which contains a function concat - it can merge two bytes. I have deployed a contract which uses that library and it works. I would like to make a simple bytes builder on my website. ...
0
votes
1answer
27 views

pass storage through interface to library

Here is what am i doing: There is a library, accept storage argument as parameter, then do some math and return the result. And there is a contract to call the function in the library, and an extra ...
0
votes
1answer
16 views

Link library to contract without migrations

To link library in migrations I use: await deployer.deploy(MyTokenL) await deployer.link(MyTokenL, MyToken) We want to use migrations as infrastructure deployment and then have a deployment factory ...
0
votes
0answers
45 views

getting error error TypeError: Member “isContract” not found or not visible after argument-dependent lookup in address payable

Using Solidity 0.4.17, I have defined a simple library at ./Addresses.sol function isContract(address _base) external pure returns(bool) { assembly { _r := gt(extcodesize(_base), 0) ...
0
votes
1answer
127 views

Contract libraries structure

I have pretty big smart contract with a lot of structs. Each struct has in average 3-4 related methods (i.e. methods with first parameter MyLibrary.MyType storage self). Question about code ...