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.

Filter by
Sorted by
Tagged with
1
vote
0answers
28 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
218 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
262 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
97 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; } ...
1
vote
1answer
68 views

How do types inherit from libraries?

When you're using a library like SafeMath, and then have using SafeMath for uint256; within a contract, how do uints know to become the a parameter of the library functions? Is that just a convention ...
4
votes
1answer
1k views

(Sub) contract vs. library vs. struct vs. Interface

First I googled and read through these questions: Creating multiple contracts or Single contract with struct Child contract vs struct Why are so many examples using separated contracts (e.g. crowed ...
2
votes
1answer
412 views

Verifying contracts with libraries

I have a problem very similar to this Cannot verify contracts with libraries on Etherscan Simple code pragma solidity ^0.4.16; //optimization enabled library C { function a() returns (address) { ...
0
votes
1answer
26 views

Workaround for testRPC bug where amounts spent multiple time with library calls?

Using testRPC the amount transferred is multiple times of the msg.value if a library call is involved. There is bug report and it was raised here and here as well. It's a well documented, long ...
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 ...
9
votes
1answer
548 views

Finding and linking to libraries

Contracts\Libraries like ERC20 and SafeMath have probably been deployed many times to Ethereum. How do I find their addresses so I can reuse their logic instead of coping them and deploying them by ...
2
votes
2answers
918 views

Is it possible for a smart contract to be able to adjust it's conditions based on the current value of Ethereum?

I ask this because I want to create a crowdfunding smart contract for a platform much like Kickstarter. At this point, the only crypto asset I want the contract to raise is Ether with the possibility ...
1
vote
1answer
46 views

`vendor/` sub-directory relationship to 3rd party dependencies

In the -go-ethereum client directory I've run the command find . -name \*.md -print looking for README.md files. The output is as follows: ./.github/CONTRIBUTING.md ./.github/ISSUE_TEMPLATE....
0
votes
2answers
748 views

How would you install the Ethminer without sudo access?

I am trying to get Genoil's Ethminer installed on a machine without sudo access. The Github instructions require some packages to be installed. sudo apt-get install git cmake libcryptopp-dev ...
0
votes
1answer
134 views

Payable function 'charges' sender twice value sent in tx after invoking library function

Facing a nasty bug and could really use a pair of fresh eyes. I have a payable function that is somehow taking twice the value sent to it by the sender, from the sender. Specifically, it appears to ...
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 ...
3
votes
1answer
1k views

(Solidity) Inheritance: how to add additional attributes to a struct in base contract?

This is a very simplified example but it of course extends to more complicated contracts too, I just haven't found an elegant solution. contract Group { struct Person { uint age; ...
10
votes
3answers
948 views

Solidity: accessing a library constant in a contract that imports the library

Is it possible to access a library constant in a contract that imports the library? I am using solidity 0.4.11 For instance: library Lib { bytes1 constant flag = 0x01 ... } separate file ...
5
votes
2answers
250 views

Sending ethers with mocha.js and truffle might result in larger sums than intended

Good day, I have a contract General and a library GenLib. library GenLib{ event MoneyIn (address _from, uint256 _amount); function moneyIn() { MoneyIn(msg.sender, msg.value); <- ...
1
vote
1answer
100 views

Is there an Ethereum javascript library to work with creating and validating addresses?

There are a bunch of ethereum sites with alot of js functionality already, but how did they do this when there is no js library that I can find? Is there a javascript library for working with Ethereum?...
0
votes
1answer
91 views

Modifer Inheritance, Unexpected Result

The setup of the contracts has 3 contracts: a library contract, a Controller contract with modifiers and a main contract as follows: DataSet.sol library DataSet { struct IndexValue { uint ...
3
votes
1answer
694 views

Linking contracts via library contract

The problem involves 3 contracts with an interdependence as follows: library --> ProductContract --> BillingContract The contracts are structured as follows: (The DataSet.sol contract below is ...
8
votes
1answer
680 views

Are internal functions in libraries not covered by linking?

According to the documenation when using a library with internal functions, the function's bytecode gets inlined into the calling contract's function. Can someone confirm if the following is ...
2
votes
1answer
218 views

Need help with solidity library deployment

I have an issue with a simple library configuration and I need an advise to resolve this. Context: Local private block chain Version: > web3.version { api: "0.18.1", ethereum: "0x3f", ...
2
votes
1answer
535 views

How to use Library with 1 File on browser solidity?

I use browser solidity. Now, I wanna create this C Contract. But, I have a message "Deploying and liking required libraries" on the right side of the picture. I have already create Math Library, and ...
0
votes
2answers
835 views

How does solidity online compiler link libraries?

Suppose I have this code: import "github.com/Arachnid/solidity-stringutils/strings.sol"; contract Contract { using strings for *; // ... } For this solidity online compiler generates this ...
4
votes
2answers
346 views

Usage of ENS for contract upgrade

Situation: let's assume we have a data storage contract libraries that import the data storage contract a business logic contract that implements the libraries Question: can we use ENS, or more ...
10
votes
1answer
5k views

How to call a library contract

library ECVerify is deployed on 0x3bbb367afe5075e0461f535d6ed2a640822edb1c on the Ropsten test net. How do I call function ecverify(bytes32 hash, bytes sig, address signer) returns (bool) {} in that ...
4
votes
1answer
461 views

Watching events defined in libraries

Is it possible to watch for event triggers when the actual event and trigger is defined in a library? I get no console output with the following code library ObjectHistoryLib { event ...
6
votes
1answer
2k views

How can I deploy a contract with reference to a library contract without using a graphical user interface like Browser Solidity?

I am using Solidity Browser to deploy a contract due to from Library contract method failing #2831 issue. On this following answer https://ethereum.stackexchange.com/a/9181/4575 I have guided to use ...
6
votes
2answers
1k views

How to make a library address updatable

I want to write a contract that uses a library. This library should be exchangable. Meaning I want the contract to have an updatable (only by owner) address variable always pointing to the current ...
9
votes
1answer
3k views

How to link libraries in browser-solidity? [duplicate]

How to link library in browser-solidity? While creating a contract using library, solidity compiler requires to link the contract with the library. But there is no options in the browser to provide it....
4
votes
1answer
198 views

Is it possible to get an address of a struct in the Library or Contract without using mapping?

[Q] I was wondering is it possible to get an address of a struct on the memory space? Inside initialise() function after the Node object creation, I want to get is address if it is possible. Since ...
5
votes
1answer
470 views

return (bytes32,bytes32) , returns actual transaction address instead of the real data

I have attached my contract, which works fine on populus and compiles on geth. It is a simple source code: Test() function appends data into my linkedlist that is defined in my library. And get() ...
2
votes
1answer
592 views

Is there a Solidity library for generating addresses?

I'm generating a few thousand addresses to test a contract, could I do that in Solidity, or do I have to use something like ethereumjs-lib ?
10
votes
2answers
2k views

Trying to understand libraries

I have a library which I want to deploy followed by a number of differing contracts which link to it. However I seem to me missing some understanding about library deployment and utilisation. The ...
27
votes
1answer
13k views

How does the delegatecall method work to call to another contract's method?

I'm trying to figure out how to use the delegatecall method on a contract address in a contract to call a function in a separate contract. I know Libraries are the higher level interface to use but I ...
3
votes
1answer
208 views

Solidity events in libraries - not displaying correctly in Mist

Has anybody been successful in executing and viewing events (in Mist) generated from solidity libraries? My contract can log and display events in the contract but events in the associated libraries ...
4
votes
1answer
634 views

Using 2 libraries with a contract in a sol file

I have a sol file with a library and also a contract. The contract can use the library and everythings deploys correct using the solidity-browser. If I add a new library and call a function of that ...
36
votes
2answers
5k views

What are the steps to compile and deploy a library in Solidity?

I have several pieces of documentation about libraries, but I am not yet able to infer what steps are needed to compile and deploy a library and then a contract that uses it. The behavior of the ...
6
votes
1answer
686 views

Accessing calling contract storage in a library

I need to understand how is it possible to access the calling contract storage from library code. From Solidity manual: This means that if library functions are called, their code is executed in ...
4
votes
1answer
490 views

How to access a mapping in a library?

library Lib{ struct Data { mapping (uint => uint) a; } function inc(Data self) internal{ self.a[0] =+1; } } contract Example{ address recipient = ...
4
votes
4answers
5k views

Ethereum library for iOS/Android?

Are there any existing native libraries (not whole wallets, I do not need a UI but want to sign transactions and call smart contract functions embedded in another app) for iOS or Android? If not, are ...
9
votes
1answer
3k views

Finding and Using Solidity Libraries (ie. Math functions)

How do I find and use any existing Solidity libraries like you might in Javascript? For example, Math functions: How do I implement the equivalent of Math.sqrt(x) in a solidity function? Related: ...
7
votes
3answers
2k views

How to import solidity libraries in mix?

Working in the MIX environment, I'd like to try using a libraries and contracts defined in different files. However, the main contract always gets an error from MIX, no matter how I define the "...
4
votes
1answer
317 views

Out of gas error deploying library

The following code is compiled with solc 0.3 with correct --libraries linking and deployed to morden. Math library is deployed just fine and can be accessed. However A doesn't get deployed on morden ...
1
vote
1answer
550 views

Is there something like bitcore for Ethereum?

In Bitcoin there is a library named Bitcore. It helps abstract away a number of details, including using direct RPC commands. Is there something like Bitcore for Ethereum? Or do I need to use JSON-...
2
votes
2answers
515 views

How can I program my DApp to tell my user that their action/transaction has been confirmed?

Take an example of a voting DApp. A user clicks on a vote button, then behind the scenes the transaction containing the vote gets mined on the blockchain. The DApp then wants to alert('You have ...
16
votes
5answers
17k views

Is there a C# implementation available for Ethereum?

Is there a C# / .NET / Mono implementation available for Ethereum to interact with nodes and/or the blockchain?
8
votes
1answer
456 views

How to handle library function prototype changes?

One great thing about using a library is that the library code can be modified, and as long as the api function prototype stays the same, all we need to do is point to the new address of the updated ...