WTF Solidity极简入门第十八讲: Import

This article is not available in the current language yet. Showing the original version.
本文介绍了利用import关键字导入外部源代码的方法。

原文:《Solidity 极简入门: 18.Import》

我最近在重新学 solidity,巩固一下细节,也写一个「Solidity 极简入门」,供小白们使用(编程大佬可以另找教程),每周更新 1-3 讲。

所有代码和教程开源在 github:github.com/AmazingAng/WTFSolidity

solidity 支持利用 import 关键字导入其他源代码中的合约,让开发更加模块化。

import 用法

通过源文件相对位置导入,例子:

WTF Solidity极简入门第十八讲: Import

通过源文件网址导入网上的合约

WTF Solidity极简入门第十八讲: Import

通过 npm 的目录导入

WTF Solidity极简入门第十八讲: Import

通过全局符号导入特定的合约

WTF Solidity极简入门第十八讲: Import

测试导入结果

我们可以用下面这段代码测试是否成功导入了外部源代码:

WTF Solidity极简入门第十八讲: Import

总结

这一讲,我们介绍了利用 import 关键字导入外部源代码的方法。import 可以让我们直接导入别人写好的代码,非常方便。

推特:@0xAA_Science

社区:Discord微信群官网 wtf.academy

所有代码和教程开源在github: github.com/AmazingAng/WTFSolidity

Share to:

Author: 0xAA

Opinions belong to the column author and do not represent PANews.

This content is not investment advice.

Image source: 0xAA. If there is any infringement, please contact the author for removal.

Follow PANews official accounts, navigate bull and bear markets together
PANews APP
It is suspected that the Dragonfly address transferred 137 million SKY tokens to Coinbase, a decrease in value of more than half compared to when the tokens were withdrawn.
PANews Newsflash