Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
1answer
12 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
34 views

Solidity modifiers in library?

Isn't it possible to define modifiers in libraries? I'm really asking myself why, because thats some functionality you would need over and over again. If I would like to hypothetically implement some ...
0
votes
1answer
12 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
1answer
31 views

Can a library use another library?

Is it possible to use a library within a library? library L2 { //... } library L1 { using L2 for *; //... } This compiles and runs just fine but what I really want to know is if L1 is ...
0
votes
0answers
34 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) ...
2
votes
0answers
19 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; } } ...
1
vote
1answer
49 views

unable to understand how to use internal function types

I need help to understand below code which is from solidity offical documents "how to use internal function types". as it is very confusing for me. How to use library in solidity. Some one explain ...
1
vote
1answer
59 views

Why does this function not need a require statement?

Why does the following function not need a require statment? function transferFrom(address from, address to, uint256 value) public returns (bool) { _allowed[from][msg.sender] = _allowed[from][...
1
vote
0answers
39 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
81 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 ...
2
votes
0answers
79 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
1answer
23 views

Why won't remix finish launching all of my libraries?

I've run into an issue. I have a contract with a hierarchy of libraries (some lower level libraries import higher level libraries). All libraries are ultimately imported by our main contract. ...
2
votes
1answer
86 views

How does a contract know which library to query or know the library address?

How does a contract know which library to query? For Example in the code below (The code is from solidity docs: https://solidity.readthedocs.io/en/v0.4.24/contracts.html?highlight=library#libraries ...
1
vote
0answers
66 views

How to use delegate call with external Library contract?

Here is my Library Contract deployed at 0xdeadbeef: library UsefulLib { function caculateAddress(address origin, uint nonce) pure external returns (address) { if(nonce == 0x00)...
1
vote
0answers
42 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
134 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
162 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 ...
0
votes
1answer
152 views

Solidity SafeMath library best practice use cases

I understand why and how to use the SafeMath library. However, I was wondering if there is a kind of best practice guide how and when to use the library and in which cases you don't have to. From a ...
0
votes
1answer
145 views

Unable to retrieve struct from mapping

I have a mapping like this: pragma solidity 0.4.24; pragma experimental ABIEncoderV2; pragma experimental "v0.5.0"; ... mapping(bytes32 => LibMarket.Market) public hashToMarket; where each ...
2
votes
0answers
43 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
132 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 ...
0
votes
1answer
115 views

Trouble with libraries (Remix)

Tried out libraries for the first time, had a really bad experience with them. I need some help in getting my contracts to work between libraries. Library 1: pragma solidity ^0.4.0; library ...
0
votes
1answer
169 views

Upradeable proxy library throws on any function, how to connect proxy and maincontract

I'm trying to implement a proxy library through the techniques researched by openZeppelin using proxies. I have 4 contracts 1. Library with logic 2. Library containing the interface for the logic ...
1
vote
1answer
362 views

Using a library to change storage

I'm trying to learn about using libraries in solidity. In the following test contract, swapNumberLib does not successfully set value1 = value2. I thought libraries could act on the storage of a ...
2
votes
0answers
138 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 ...
0
votes
1answer
137 views

OpenZeppelin ECRecovery does not work

I am trying to use the OpenZeppelin ECRecovery library for a project I am working on. Unfortunately I don't fully understand how it works and there's no documentation for it. Let's say I want to ...
0
votes
1answer
112 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 ...
1
vote
0answers
41 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 ...
1
vote
2answers
494 views

SafeMath library vs SafeMath contract on the inheritance chain

guys, I am developing ERC-20 token and I am wondering why SafeMath is used as as library in the OpenZeppelin implementation? Will not it be more optimal if we supply it as a base contract on the ...
0
votes
2answers
780 views

Can I define global variables in Library contract?

I want to use some variables in multiple functions in my library contract. Is there any way to do that? I got following error code for my library code. library myArithmetic { bytes1[10] mData; ...
1
vote
1answer
49 views

Using 3rd party libraries in production

In the case where you wish to use a library that someone else has written for your own contract, is it generally best practice to link to the developer's own deployment of their library? Or should you ...
2
votes
0answers
104 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); } } ...
0
votes
1answer
226 views

Error: invalid solidity type!: (library.enum)

Consider the following sample Truffle project: . ├── contracts │   ├── Foo.sol │   └── Migrations.sol ├── migrations │   ├── 1_initial_migration.js │   └── 2_foo.js ├── test │   └── Foo.test.js └── ...
3
votes
1answer
279 views

Is it possible to use a solidity library inside another?

I am trying to use a solidity library inside another. The minimal code would be something like this: The deepest library: SLib.sol pragma solidity ^0.4.18; library SLib { struct SCtx { uint a;...
3
votes
1answer
1k views

Difference between library-using-for and contract-is

I am using two different ways to get the same result and wondering what the real difference is. Both options (library, using, for and contract, is)deliver just an extended code from a file. Method no ...
4
votes
0answers
189 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 ...
1
vote
1answer
336 views

Reputable Solidity utils library for arrays

Is there an audited and reputable smart contracts utils library with helpers for dealing with arrays? I haven't found anything great on Google so far.
1
vote
2answers
589 views

@dev and @title in solidity [duplicate]

When we use built-in library in solidity smart contract, why we need to use @dev and @title annotation? My code is like below: /** *@title SafeMath *@dev Math operations with safety checks that ...
0
votes
1answer
72 views

Building Ethereum application with in-process client

Most applications connect to an Ethereum Node through RPC, using a library like Web3.js and Nethereum. That introduces a need to deploy a full node side-by-side with the application, be it on the ...
2
votes
0answers
190 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 ...
0
votes
3answers
76 views

Ethereum Dapp Library

I would like to build Dapps on top of Ethereum and have a lot of ideas but the Solidity language is a bit difficult (at least to me). Is there a Windows library or a portable command line tool that ...
1
vote
1answer
301 views

Library gets automatically included in contract

environment: all contracts use pragma solidity ^0.4.17; the compiler is 0.4.18+commit.9cf6e910.Emscripten.clang OS is MacOS X My token contract uses a Math library that is defined like so library ...
1
vote
1answer
143 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 ...
1
vote
1answer
835 views

link libraries with smart contracts

I have created library and imported in my contract. I am not able to link the library in deployment file. solution needed. thanks in adv pragma solidity ^0.4.2; library StringUtils { /// @dev ...
2
votes
0answers
81 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
1answer
355 views

Importing a contract from GitHub

I'm trying to import a contract from GitHub: pragma solidity ^0.4.18; pragma experimental ABIEncoderV2; pragma experimental "v0.5.0"; import "github.com/ethereum/dapp-bin/library/stringUtils.sol"; ...
1
vote
0answers
27 views

How to import libraries to Mist? [duplicate]

I've create a contract in Remix imporing 2 differents libreries and it works ok, but when I copy and paste it into Mist I got an error at the import statement. Code goes like this: pragma solidity ^...
3
votes
1answer
210 views

Help to understand library linking and the multisig hack [duplicate]

Just read about the today issue with parity multisig wallets, https://paritytech.io/blog/security-alert.html where as far I can understand the problem is that a library linked to many wallets was ...
1
vote
1answer
243 views

Solidity Library call gives Member not found or not visible after argument-dependent lookup

Using Solidity 0.4.17, I have defined a simple library at ./StringUtils.sol library StringUtils { function isEmptyString(string s) external pure returns (bool) { return (keccak256(s) == ...
1
vote
1answer
93 views

library, not found or visible after argument-dependent lookup in type

I am trying to understand libraries and I keep running in to "not found or visible after argument-dependent lookup in type". pragma solidity ^0.4.17; library L{ struct S{ uint UI; } ...