1

Looking at the solidity documentation i don´t find a date type. Searching in the web I find a GitHub repo that appear one contract that give the posibility to work with date.

https://github.com/pipermerriam/ethereum-datetime/blob/master/contracts/DateTime.sol

My problem is that I don´t know how can import one contract inside other contract. Any help??

3

You can do this by putting this contract in your directory and importing it in your main contract and inherit it. You can import any file by using this syntax on the top of your file: import <filename>;

You can check various ways to import here: https://solidity.readthedocs.io/en/v0.5.0/layout-of-source-files.html?highlight=import#import

To understand inheritance in solidity, this can be helpful : https://solidity.readthedocs.io/en/v0.5.0/contracts.html#inheritance

To avoid import, you can directly copy the contract in the same file of your contract.

| improve this answer | |
1

You can import directly like: enter image description here

but there is some error in import link:https://github.com/pipermerriam/ethereum-datetime/blob/master/contracts/DateTime.sol

So, You can import it in another way like go to this Github link and copy all content of DateTime.sol file and create the same name of a file in your remix IDE and import it.

| improve this answer | |
1

In solidity we can import a contract in different ways.

Simple way of importing contract:

import "<filename>";

Using a global symbol whose members are all the global symbols from contract file :

import * as globalSymbolName from "<filename>";

For avoiding name collision in contracts we can use alias :

import {symbol1 as alias, symbol2} from "filename";

By specifying path :

import "./filename" as filename;

import "<contract url>" as mapping_name;

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.